zed/crates/terminal_view
renovate[bot] 6c8836ec21
Update Rust crate itertools to v0.13.0 (#17048)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [itertools](https://togithub.com/rust-itertools/itertools) |
dependencies | minor | `0.10` -> `0.13` |
| [itertools](https://togithub.com/rust-itertools/itertools) |
workspace.dependencies | minor | `0.11.0` -> `0.13.0` |

---

### Release Notes

<details>
<summary>rust-itertools/itertools (itertools)</summary>

###
[`v0.13.0`](https://togithub.com/rust-itertools/itertools/blob/HEAD/CHANGELOG.md#0130)

[Compare
Source](https://togithub.com/rust-itertools/itertools/compare/v0.12.1...v0.13.0)

##### Breaking

- Removed implementation of `DoubleEndedIterator` for `ConsTuples`
([#&#8203;853](https://togithub.com/rust-itertools/itertools/issues/853))
- Made `MultiProduct` fused and fixed on an empty iterator
([#&#8203;835](https://togithub.com/rust-itertools/itertools/issues/835),
[#&#8203;834](https://togithub.com/rust-itertools/itertools/issues/834))
- Changed `iproduct!` to return tuples for maxi one iterator too
([#&#8203;870](https://togithub.com/rust-itertools/itertools/issues/870))
- Changed `PutBack::put_back` to return the old value
([#&#8203;880](https://togithub.com/rust-itertools/itertools/issues/880))
- Removed deprecated `repeat_call, Itertools::{foreach, step,
map_results, fold_results}`
([#&#8203;878](https://togithub.com/rust-itertools/itertools/issues/878))
- Removed `TakeWhileInclusive::new`
([#&#8203;912](https://togithub.com/rust-itertools/itertools/issues/912))

##### Added

- Added `Itertools::{smallest_by, smallest_by_key, largest, largest_by,
largest_by_key}`
([#&#8203;654](https://togithub.com/rust-itertools/itertools/issues/654),
[#&#8203;885](https://togithub.com/rust-itertools/itertools/issues/885))
- Added `Itertools::tail`
([#&#8203;899](https://togithub.com/rust-itertools/itertools/issues/899))
- Implemented `DoubleEndedIterator` for `ProcessResults`
([#&#8203;910](https://togithub.com/rust-itertools/itertools/issues/910))
- Implemented `Debug` for `FormatWith`
([#&#8203;931](https://togithub.com/rust-itertools/itertools/issues/931))
- Added `Itertools::get`
([#&#8203;891](https://togithub.com/rust-itertools/itertools/issues/891))

##### Changed

- Deprecated `Itertools::group_by` (renamed `chunk_by`)
([#&#8203;866](https://togithub.com/rust-itertools/itertools/issues/866),
[#&#8203;879](https://togithub.com/rust-itertools/itertools/issues/879))
- Deprecated `unfold` (use `std::iter::from_fn` instead)
([#&#8203;871](https://togithub.com/rust-itertools/itertools/issues/871))
- Optimized `GroupingMapBy`
([#&#8203;873](https://togithub.com/rust-itertools/itertools/issues/873),
[#&#8203;876](https://togithub.com/rust-itertools/itertools/issues/876))
- Relaxed `Fn` bounds to `FnMut` in `diff_with,
Itertools::into_group_map_by`
([#&#8203;886](https://togithub.com/rust-itertools/itertools/issues/886))
- Relaxed `Debug/Clone` bounds for `MapInto`
([#&#8203;889](https://togithub.com/rust-itertools/itertools/issues/889))
- Documented the `use_alloc` feature
([#&#8203;887](https://togithub.com/rust-itertools/itertools/issues/887))
- Optimized `Itertools::set_from`
([#&#8203;888](https://togithub.com/rust-itertools/itertools/issues/888))
- Removed badges in `README.md`
([#&#8203;890](https://togithub.com/rust-itertools/itertools/issues/890))
- Added "no-std" categories in `Cargo.toml`
([#&#8203;894](https://togithub.com/rust-itertools/itertools/issues/894))
- Fixed `Itertools::k_smallest` on short unfused iterators
([#&#8203;900](https://togithub.com/rust-itertools/itertools/issues/900))
- Deprecated `Itertools::tree_fold1` (renamed `tree_reduce`)
([#&#8203;895](https://togithub.com/rust-itertools/itertools/issues/895))
- Deprecated `GroupingMap::fold_first` (renamed `reduce`)
([#&#8203;902](https://togithub.com/rust-itertools/itertools/issues/902))
- Fixed `Itertools::k_smallest(0)` to consume the iterator, optimized
`Itertools::k_smallest(1)`
([#&#8203;909](https://togithub.com/rust-itertools/itertools/issues/909))
- Specialized `Combinations::nth`
([#&#8203;914](https://togithub.com/rust-itertools/itertools/issues/914))
- Specialized `MergeBy::fold`
([#&#8203;920](https://togithub.com/rust-itertools/itertools/issues/920))
- Specialized `CombinationsWithReplacement::nth`
([#&#8203;923](https://togithub.com/rust-itertools/itertools/issues/923))
- Specialized `FlattenOk::{fold, rfold}`
([#&#8203;927](https://togithub.com/rust-itertools/itertools/issues/927))
- Specialized `Powerset::nth`
([#&#8203;924](https://togithub.com/rust-itertools/itertools/issues/924))
- Documentation fixes
([#&#8203;882](https://togithub.com/rust-itertools/itertools/issues/882),
[#&#8203;936](https://togithub.com/rust-itertools/itertools/issues/936))
- Fixed `assert_equal` for iterators longer than `i32::MAX`
([#&#8203;932](https://togithub.com/rust-itertools/itertools/issues/932))
- Updated the `must_use` message of non-lazy `KMergeBy` and
`TupleCombinations`
([#&#8203;939](https://togithub.com/rust-itertools/itertools/issues/939))

##### Notable Internal Changes

- Tested iterator laziness
([#&#8203;792](https://togithub.com/rust-itertools/itertools/issues/792))
- Created `CONTRIBUTING.md`
([#&#8203;767](https://togithub.com/rust-itertools/itertools/issues/767))

###
[`v0.12.1`](https://togithub.com/rust-itertools/itertools/blob/HEAD/CHANGELOG.md#0121)

[Compare
Source](https://togithub.com/rust-itertools/itertools/compare/v0.12.0...v0.12.1)

##### Added

- Documented iteration order guarantee for
`Itertools::[tuple_]combinations`
([#&#8203;822](https://togithub.com/rust-itertools/itertools/issues/822))
- Documented possible panic in `iterate`
([#&#8203;842](https://togithub.com/rust-itertools/itertools/issues/842))
- Implemented `Clone` and `Debug` for `Diff`
([#&#8203;845](https://togithub.com/rust-itertools/itertools/issues/845))
- Implemented `Debug` for `WithPosition`
([#&#8203;859](https://togithub.com/rust-itertools/itertools/issues/859))
- Implemented `Eq` for `MinMaxResult`
([#&#8203;838](https://togithub.com/rust-itertools/itertools/issues/838))
- Implemented `From<EitherOrBoth<A, B>>` for `Option<Either<A, B>>`
([#&#8203;843](https://togithub.com/rust-itertools/itertools/issues/843))
- Implemented `PeekingNext` for `RepeatN`
([#&#8203;855](https://togithub.com/rust-itertools/itertools/issues/855))

##### Changed

- Made `CoalesceBy` lazy
([#&#8203;801](https://togithub.com/rust-itertools/itertools/issues/801))
- Optimized `Filter[Map]Ok::next`, `Itertools::partition`,
`Unique[By]::next[_back]`
([#&#8203;818](https://togithub.com/rust-itertools/itertools/issues/818))
- Optimized `Itertools::find_position`
([#&#8203;837](https://togithub.com/rust-itertools/itertools/issues/837))
- Optimized `Positions::next[_back]`
([#&#8203;816](https://togithub.com/rust-itertools/itertools/issues/816))
- Optimized `ZipLongest::fold`
([#&#8203;854](https://togithub.com/rust-itertools/itertools/issues/854))
- Relaxed `Debug` bounds for `GroupingMapBy`
([#&#8203;860](https://togithub.com/rust-itertools/itertools/issues/860))
- Specialized `ExactlyOneError::fold`
([#&#8203;826](https://togithub.com/rust-itertools/itertools/issues/826))
- Specialized `Interleave[Shortest]::fold`
([#&#8203;849](https://togithub.com/rust-itertools/itertools/issues/849))
- Specialized `MultiPeek::fold`
([#&#8203;820](https://togithub.com/rust-itertools/itertools/issues/820))
- Specialized `PadUsing::[r]fold`
([#&#8203;825](https://togithub.com/rust-itertools/itertools/issues/825))
- Specialized `PeekNth::fold`
([#&#8203;824](https://togithub.com/rust-itertools/itertools/issues/824))
- Specialized `Positions::[r]fold`
([#&#8203;813](https://togithub.com/rust-itertools/itertools/issues/813))
- Specialized `PutBackN::fold`
([#&#8203;823](https://togithub.com/rust-itertools/itertools/issues/823))
- Specialized `RepeatN::[r]fold`
([#&#8203;821](https://togithub.com/rust-itertools/itertools/issues/821))
- Specialized `TakeWhileInclusive::fold`
([#&#8203;851](https://togithub.com/rust-itertools/itertools/issues/851))
- Specialized `ZipLongest::rfold`
([#&#8203;848](https://togithub.com/rust-itertools/itertools/issues/848))

##### Notable Internal Changes

- Added test coverage in CI
([#&#8203;847](https://togithub.com/rust-itertools/itertools/issues/847),
[#&#8203;856](https://togithub.com/rust-itertools/itertools/issues/856))
- Added semver check in CI
([#&#8203;784](https://togithub.com/rust-itertools/itertools/issues/784))
- Enforced `clippy` in CI
([#&#8203;740](https://togithub.com/rust-itertools/itertools/issues/740))
- Enforced `rustdoc` in CI
([#&#8203;840](https://togithub.com/rust-itertools/itertools/issues/840))
- Improved specialization tests
([#&#8203;807](https://togithub.com/rust-itertools/itertools/issues/807))
- More specialization benchmarks
([#&#8203;806](https://togithub.com/rust-itertools/itertools/issues/806))

###
[`v0.12.0`](https://togithub.com/rust-itertools/itertools/blob/HEAD/CHANGELOG.md#0120)

[Compare
Source](https://togithub.com/rust-itertools/itertools/compare/v0.11.0...v0.12.0)

##### Breaking

- Made `take_while_inclusive` consume iterator by value
([#&#8203;709](https://togithub.com/rust-itertools/itertools/issues/709))
- Added `Clone` bound to `Unique`
([#&#8203;777](https://togithub.com/rust-itertools/itertools/issues/777))

##### Added

- Added `Itertools::try_len`
([#&#8203;723](https://togithub.com/rust-itertools/itertools/issues/723))
- Added free function `sort_unstable`
([#&#8203;796](https://togithub.com/rust-itertools/itertools/issues/796))
- Added `GroupMap::fold_with`
([#&#8203;778](https://togithub.com/rust-itertools/itertools/issues/778),
[#&#8203;785](https://togithub.com/rust-itertools/itertools/issues/785))
- Added `PeekNth::{peek_mut, peek_nth_mut}`
([#&#8203;716](https://togithub.com/rust-itertools/itertools/issues/716))
- Added `PeekNth::{next_if, next_if_eq}`
([#&#8203;734](https://togithub.com/rust-itertools/itertools/issues/734))
- Added conversion into `(Option<A>,Option<B>)` to `EitherOrBoth`
([#&#8203;713](https://togithub.com/rust-itertools/itertools/issues/713))
- Added conversion from `Either<A, B>` to `EitherOrBoth<A, B>`
([#&#8203;715](https://togithub.com/rust-itertools/itertools/issues/715))
- Implemented `ExactSizeIterator` for `Tuples`
([#&#8203;761](https://togithub.com/rust-itertools/itertools/issues/761))
- Implemented `ExactSizeIterator` for `(Circular)TupleWindows`
([#&#8203;752](https://togithub.com/rust-itertools/itertools/issues/752))
- Made `EitherOrBoth<T>` a shorthand for `EitherOrBoth<T, T>`
([#&#8203;719](https://togithub.com/rust-itertools/itertools/issues/719))

##### Changed

- Added missing `#[must_use]` annotations on iterator adaptors
([#&#8203;794](https://togithub.com/rust-itertools/itertools/issues/794))
- Made `Combinations` lazy
([#&#8203;795](https://togithub.com/rust-itertools/itertools/issues/795))
- Made `Intersperse(With)` lazy
([#&#8203;797](https://togithub.com/rust-itertools/itertools/issues/797))
- Made `Permutations` lazy
([#&#8203;793](https://togithub.com/rust-itertools/itertools/issues/793))
- Made `Product` lazy
([#&#8203;800](https://togithub.com/rust-itertools/itertools/issues/800))
- Made `TupleWindows` lazy
([#&#8203;602](https://togithub.com/rust-itertools/itertools/issues/602))
- Specialized `Combinations::{count, size_hint}`
([#&#8203;729](https://togithub.com/rust-itertools/itertools/issues/729))
- Specialized `CombinationsWithReplacement::{count, size_hint}`
([#&#8203;737](https://togithub.com/rust-itertools/itertools/issues/737))
- Specialized `Powerset::fold`
([#&#8203;765](https://togithub.com/rust-itertools/itertools/issues/765))
- Specialized `Powerset::count`
([#&#8203;735](https://togithub.com/rust-itertools/itertools/issues/735))
- Specialized `TupleCombinations::{count, size_hint}`
([#&#8203;763](https://togithub.com/rust-itertools/itertools/issues/763))
- Specialized `TupleCombinations::fold`
([#&#8203;775](https://togithub.com/rust-itertools/itertools/issues/775))
- Specialized `WhileSome::fold`
([#&#8203;780](https://togithub.com/rust-itertools/itertools/issues/780))
- Specialized `WithPosition::fold`
([#&#8203;772](https://togithub.com/rust-itertools/itertools/issues/772))
- Specialized `ZipLongest::fold`
([#&#8203;774](https://togithub.com/rust-itertools/itertools/issues/774))
- Changed `{min, max}_set*` operations require `alloc` feature, instead
of `std`
([#&#8203;760](https://togithub.com/rust-itertools/itertools/issues/760))
- Improved documentation of `tree_fold1`
([#&#8203;787](https://togithub.com/rust-itertools/itertools/issues/787))
- Improved documentation of `permutations`
([#&#8203;724](https://togithub.com/rust-itertools/itertools/issues/724))
- Fixed typo in documentation of `multiunzip`
([#&#8203;770](https://togithub.com/rust-itertools/itertools/issues/770))

##### Notable Internal Changes

- Improved specialization tests
([#&#8203;799](https://togithub.com/rust-itertools/itertools/issues/799),
[#&#8203;786](https://togithub.com/rust-itertools/itertools/issues/786),
[#&#8203;782](https://togithub.com/rust-itertools/itertools/issues/782))
- Simplified implementation of `Permutations`
([#&#8203;739](https://togithub.com/rust-itertools/itertools/issues/739),
[#&#8203;748](https://togithub.com/rust-itertools/itertools/issues/748),
[#&#8203;790](https://togithub.com/rust-itertools/itertools/issues/790))
- Combined `Merge`/`MergeBy`/`MergeJoinBy` implementations
([#&#8203;736](https://togithub.com/rust-itertools/itertools/issues/736))
- Simplified `Permutations::size_hint`
([#&#8203;739](https://togithub.com/rust-itertools/itertools/issues/739))
- Fix wrapping arithmetic in benchmarks
([#&#8203;770](https://togithub.com/rust-itertools/itertools/issues/770))
- Enforced `rustfmt` in CI
([#&#8203;751](https://togithub.com/rust-itertools/itertools/issues/751))
- Disallowed compile warnings in CI
([#&#8203;720](https://togithub.com/rust-itertools/itertools/issues/720))
- Used `cargo hack` to check MSRV
([#&#8203;754](https://togithub.com/rust-itertools/itertools/issues/754))

###
[`v0.11.0`](https://togithub.com/rust-itertools/itertools/blob/HEAD/CHANGELOG.md#0110)

[Compare
Source](https://togithub.com/rust-itertools/itertools/compare/v0.10.5...v0.11.0)

##### Breaking

- Make `Itertools::merge_join_by` also accept functions returning bool
([#&#8203;704](https://togithub.com/rust-itertools/itertools/issues/704))
- Implement `PeekingNext` transitively over mutable references
([#&#8203;643](https://togithub.com/rust-itertools/itertools/issues/643))
- Change `with_position` to yield `(Position, Item)` instead of
`Position<Item>`
([#&#8203;699](https://togithub.com/rust-itertools/itertools/issues/699))

##### Added

- Add `Itertools::take_while_inclusive`
([#&#8203;616](https://togithub.com/rust-itertools/itertools/issues/616))
- Implement `PeekingNext` for `PeekingTakeWhile`
([#&#8203;644](https://togithub.com/rust-itertools/itertools/issues/644))
- Add `EitherOrBoth::{just_left, just_right, into_left, into_right,
as_deref, as_deref_mut, left_or_insert, right_or_insert,
left_or_insert_with, right_or_insert_with, insert_left, insert_right,
insert_both}`
([#&#8203;629](https://togithub.com/rust-itertools/itertools/issues/629))
- Implement `Clone` for `CircularTupleWindows`
([#&#8203;686](https://togithub.com/rust-itertools/itertools/issues/686))
- Implement `Clone` for `Chunks`
([#&#8203;683](https://togithub.com/rust-itertools/itertools/issues/683))
- Add `Itertools::process_results`
([#&#8203;680](https://togithub.com/rust-itertools/itertools/issues/680))

##### Changed

- Use `Cell` instead of `RefCell` in `Format` and `FormatWith`
([#&#8203;608](https://togithub.com/rust-itertools/itertools/issues/608))
- CI tweaks
([#&#8203;674](https://togithub.com/rust-itertools/itertools/issues/674),
[#&#8203;675](https://togithub.com/rust-itertools/itertools/issues/675))
- Document and test the difference between stable and unstable sorts
([#&#8203;653](https://togithub.com/rust-itertools/itertools/issues/653))
- Fix documentation error on `Itertools::max_set_by_key`
([#&#8203;692](https://togithub.com/rust-itertools/itertools/issues/692))
- Move MSRV metadata to `Cargo.toml`
([#&#8203;672](https://togithub.com/rust-itertools/itertools/issues/672))
- Implement `equal` with `Iterator::eq`
([#&#8203;591](https://togithub.com/rust-itertools/itertools/issues/591))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 3pm on Wednesday" in timezone
America/New_York, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

Release Notes:

- N/A

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC41Ni4wIiwidXBkYXRlZEluVmVyIjoiMzguNTYuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-08-28 22:13:35 -07:00
..
scripts Clean up whitespace (#10755) 2024-04-23 13:31:21 -04:00
src Update Rust crate itertools to v0.13.0 (#17048) 2024-08-28 22:13:35 -07:00
Cargo.toml Improve Linux terminal keymap and context menu (#16845) 2024-08-26 01:01:46 +03:00
LICENSE-GPL chore: Change AGPL-licensed crates to GPL (except for collab) (#4231) 2024-01-24 00:26:58 +01:00
README.md vim . to replay 2023-09-06 13:49:55 -06:00

Design notes:

This crate is split into two conceptual halves:

  • The terminal.rs file and the src/mappings/ folder, these contain the code for interacting with Alacritty and maintaining the pty event loop. Some behavior in this file is constrained by terminal protocols and standards. The Zed init function is also placed here.
  • Everything else. These other files integrate the Terminal struct created in terminal.rs into the rest of GPUI. The main entry point for GPUI is the terminal_view.rs file and the modal.rs file.

ttys are created externally, and so can fail in unexpected ways. However, GPUI currently does not have an API for models than can fail to instantiate. TerminalBuilder solves this by using Rust's type system to split tty instantiation into a 2 step process: first attempt to create the file handles with TerminalBuilder::new(), check the result, then call TerminalBuilder::subscribe(cx) from within a model context.

The TerminalView struct abstracts over failed and successful terminals, passing focus through to the associated view and allowing clients to build a terminal without worrying about errors.

#Input

There are currently many distinct paths for getting keystrokes to the terminal:

  1. Terminal specific characters and bindings. Things like ctrl-a mapping to ASCII control character 1, ANSI escape codes associated with the function keys, etc. These are caught with a raw key-down handler in the element and are processed immediately. This is done with the try_keystroke() method on Terminal

  2. GPU Action handlers. GPUI clobbers a few vital keys by adding bindings to them in the global context. These keys are synthesized and then dispatched through the same try_keystroke() API as the above mappings

  3. IME text. When the special character mappings fail, we pass the keystroke back to GPUI to hand it to the IME system. This comes back to us in the View::replace_text_in_range() method, and we then send that to the terminal directly, bypassing try_keystroke().

  4. Pasted text has a separate pathway.

Generally, there's a distinction between 'keystrokes that need to be mapped' and 'strings which need to be written'. I've attempted to unify these under the '.try_keystroke()' API and the .input() API (which try_keystroke uses) so we have consistent input handling across the terminal