mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-27 19:09:54 +01:00
df1ba676f214cb9fdc19bef6cc024a47dc77c4f7
21 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4fd48c02ac |
Miscellaneous improvements to prepare for Rust 1.100 (#66901)
## Summary Fixes rustc and clippy warnings for a potential upcoming Rust 1.100 version bump. All changes are backwards compatible and Rust is **not** bumped in this PR. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - N/A - [GPUI] N/A --------- Co-authored-by: Finn Evers <finn.evers@outlook.de> |
||
|
|
b6ff193ba6 |
Stop showing worktree trust modal after "Stay in Restricted Mode" is called (#66649)
Closes https://github.com/zed-industries/zed/issues/58246 * Starts to remember "Stay in Restricted Mode" calls to avoid repeated worktree trust pop-ups * Uses `RemoteConnectionIdentity` instead of the prior type (removed) as more detailed remote host identifier (has a port value now) * Migrates worktree trust DB to that, more detailed, data format Release Notes: - Stopped showing worktree trust modal after "Stay in Restricted Mode" is called |
||
|
|
9fa6fd3f44 |
Worktree picker: search also by branch name (#66384)
## Summary In the worktree picker, can now search by both branch and worktree name instead of only by worktree name. With the current implementation whenever the worktree and a checked out branch do not share same name and the user wants to switch worktree, they have to remember the worktree name, or do some workaround like launching `zed .` from the worktree. It's not possible to switch worktree using the branch picker, as it will try to check out the branch in the current worktree (this change doesn't touch that behaviour). An example where it exists a branch named `a-random-branch` checked out in worktree `zed-deliberate-purpose` Before, when searching by `random` the worktree does not appear: <img width="696" height="197" alt="image" src="https://github.com/user-attachments/assets/cd1674c1-3ca6-4337-ad16-439f58df9e03" /> After, it is fuzzy matched because of the branch name: <img width="668" height="189" alt="image" src="https://github.com/user-attachments/assets/ed521e76-bc1b-4e4e-b662-7caba46ff91a" /> ## Testing I manually tested the change, but only on macOS. I have been using it for a few weeks with megarepos and tens of worktrees/branches. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Added the possibility to search also by branch name in the worktree picker. |
||
|
|
ba36af2050 |
Revert "Reduce waits for navigation, suggestions, and file comparisons (#66487)" (#66517)
This reverts commit
|
||
|
|
7e7311ad20 |
Reduce waits for navigation, suggestions, and file comparisons (#66487)
# Objective Reduce waiting when navigating code, loading details for code suggestions, and comparing files. Zed currently starts some independent file reads and requests only after the previous one finishes. ## Solution - Load up to 16 definition or reference results at once. Keep their original order. Repeated results for the same file share one read and one open copy of the file. - Request details for up to 16 code suggestions at once. Repeated item indexes produce one request. Successful items still update if one request fails. Keep the checks that each language server supports the request. - Read both sides of a file comparison together. Load up to 16 comparison pairs at once, while keeping their display order. - Add controlled-delay tests. Saved file contents and the text ranges returned by navigation stay the same. ## Testing On current `main` at `8a47b35109`: - 748 tests passed across `project`, `git_ui`, and `git_ui_core`. Four tests were already ignored. Each suite ran one test at a time. - Seven timing and behavior tests passed across 100 task execution orders each: 700 runs. They check result order, repeated files and suggestions, the request limit, errors, and cleanup. - Required `./script/clippy` passed for all three packages, with all targets and all features. Its dependency check also passed. The check used no debug symbols and `profile.release.opt-level=0` to limit build storage. - Formatting and `git diff --check` passed. The original checkout measured the following controlled delays. The port to current `main` passes the same 40 ms checks: | Operation | Before | After | | --- | ---: | ---: | | Go to definition across three unopened files | 120 ms | 40 ms | | Find references across three unopened files | 120 ms | 40 ms | | Load details for three code suggestions | 120 ms | 40 ms | | Open one file comparison | 80 ms | 40 ms | | Open three file comparisons | 240 ms | 40 ms | Each independent read or request has a deliberate 40 ms delay. These results prove reduced waiting in these cases. They do not establish a whole-application speed improvement. Remote network performance and the best concurrency limit for each machine remain unmeasured. The earlier checkout also passed all five checks in a clean-built macOS app. Those built-app checks predate this port. They are separate from the current-main checks above. Reviewers can run the focused tests with: ```sh ITERATIONS=100 cargo test -p project -p git_ui -p git_ui_core --features project/test-support concurrently -- --nocapture ``` ## Self-Review Checklist - [x] Reviewed the changes for correctness and cleanup of completed or failed work - [x] Added tests for the changed behavior and measured waiting time - [x] Kept result order and bounded active work ## Suggested .rules additions Proposed text for the project test guidance, for review in a separate rules change: > In GPUI tests that check the release of invisible worktrees, drop the final buffer handles inside `cx.update(...)`, then check the remaining worktrees. `run_until_parked()` alone does not flush deferred entity releases. Release Notes: - Improved responsiveness when navigating code, loading completion details, and comparing files. |
||
|
|
5a534d7b5d |
git: Add git auto fetch (#53089)
## Summary
Adds an opt-in periodic background `git fetch --all` for local
repositories, so remote-tracking branches and ahead/behind counts stay
current without a manual fetch.
Because the fetch runs unattended, it behaves differently from a
user-initiated fetch:
- **Trusted repositories only.** Re-checked on every tick, since a
worktree can be trusted or restricted at any point in a session.
- **Never prompts.** Credentials that need no interaction (e.g. an SSH
agent, or a credential helper answering from a keychain) still work.
Anything that would need input fails instead of blocking on a prompt
nothing will answer.
- **Silent.** No activity indicator in the status bar, since a spinner
every minute is noise. Failures are logged at debug level.
- **Stays out of the user's way.** It runs off the repository's serial
job queue, so status refreshes and staging aren't stalled behind the
network. A user-initiated fetch, pull, or push preempts an in-flight
background fetch rather than waiting for it.
- **Leaves the repository clean when stopped.** Stopping a fetch (a
settings change, preemption, closing the project) asks git to terminate
so it can remove its ref lockfiles, rather than killing it and leaving a
stale `.lock` behind that breaks every later fetch. It also never
triggers auto-maintenance on the user's behalf.
## Configuration
```json [settings]
{
"git": {
"auto_fetch": {
"enabled": false,
"interval_secs": 60
}
}
}
```
- `enabled` (default `false`): whether to fetch from all remotes in the
background.
- `interval_secs` (default `60`, clamped to a minimum of `15`): how
often to fetch.
Both are exposed in the settings UI under **Version Control > Git
Integration**, where the interval is only shown while auto-fetch is
enabled, and documented in `docs/src/reference/all-settings.md`.
Unrelated settings changes don't restart the timer.
## Implementation design
### `GitCaller`
The remote-capable `GitRepository` methods (`fetch`, `pull`, `push`,
`commit`) take a `GitCaller` instead of a bare `AskPassDelegate`:
```rust
pub enum GitCaller {
/// A user started this and is waiting on it. Prompts route to the UI.
User(AskPassDelegate),
/// No user attached. Never prompts, and stops when the receiver resolves.
Background(Option<oneshot::Receiver<()>>),
}
```
Every such command goes through `GitBinary::run_remote_command`, which
applies everything the caller implies. git, credential helpers, and ssh
each prompt through a different mechanism, so keeping the list in one
place means no call site can miss one. For `Background`:
| Prompt channel | Mitigation |
| --- | --- |
| git's own terminal prompt | `GIT_TERMINAL_PROMPT=0` |
| Credential helpers | `credential.interactive=false`, which is narrower
than clearing `credential.helper` so helpers that answer without
prompting keep working |
| askpass | `core.askPass=`, and `GIT_ASKPASS`/`SSH_ASKPASS` unset |
| ssh (key passphrases, host key confirmation) | `-o BatchMode=yes`
composed onto the ssh command git would otherwise use
(`GIT_SSH_COMMAND`, then `core.sshCommand`, then `ssh`), so custom ssh
commands keep working. Setups that only set the deprecated `GIT_SSH` are
left alone, since setting `GIT_SSH_COMMAND` would silently replace them.
|
`gc.auto=0` is also set, since auto-maintenance can repack the whole
repository. gpg's pinentry when signing isn't covered, as no background
caller signs.
### Cancellation
A background command is spawned with `kill_on_drop` and raced against
its cancel receiver, where a dropped sender counts as cancellation:
1. If already cancelled before spawning, git is never started.
2. On cancellation, git is sent `SIGTERM`
(`util::process::request_termination`), which runs its handlers that
remove lockfiles.
3. If it hasn't exited within a 2s grace period, it's killed.
Windows has no equivalent signal, so cancellation there is a kill.
### Scheduling
- Each repository has a timer task, restarted only when `enabled` or
`interval_secs` change.
- On each tick, the timer checks trust, then tries to acquire the
repository's `fetch_lock` semaphore and skips the tick if it's held. It
spawns a **detached** fetch task that holds the permit until the fetch
settles.
- `AutoFetchState.cancel` holds the sender, and is the only thing
bounding the fetch's lifetime. It's dropped on a settings change, on
preemption, and when the repository is dropped, so every way of stopping
a fetch goes through graceful cancellation.
- Running off the serial job queue is safe because auto-fetch mutates no
`Repository` state. It only updates remote-tracking refs, which git
guards with its own lockfiles, and the results reach the UI via the
resulting git directory rescan. Manual fetch stays on the queue, since
it also writes snapshot state via `refresh_branch_list`.
- `fetch`, `pull`, and `push` call `preempt_auto_fetch()`, which drops
the cancel sender, then wait on `fetch_lock` inside their job. That wait
is bounded by a cancelled fetch shutting down rather than by the
network, and stops them failing with "cannot lock ref" against a
background fetch.
## Test plan
`test_auto_fetch` covers:
- [x] An untrusted repository is never auto-fetched, and fetching begins
once its worktree is trusted
- [x] Timer fires on schedule, and again on the following interval
- [x] Unrelated settings change mid-interval doesn't reset the timer
- [x] Disabling `auto_fetch` stops all fetches
- [x] Re-enabling with a longer interval respects the new cadence
## Review
Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Addresses
#24611(https://github.com/zed-industries/zed/discussions/24611)
Release Notes:
- git: Added option (off-by-default) to automatically fetch upstream of
the current branch and default upstream of the project. Enable it with:
```
{
"git": {
"auto_fetch": {
"enabled": false,
"interval_secs": 60
}
}
}
```.
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
|
||
|
|
2e57653724 |
project: Remove the PathStyle guard for repository identity paths (#66209)
## Summary Follow-up of #63075. `repo_identity_path_if_local` is nearly identical to `repo_identity_path`; the only difference is that it returns `None` unless the path style matches the host's: https://github.com/zed-industries/zed/blob/e4a3732b94eb0881e1d954201ed41ffd2abf18f6/crates/project/src/git_store.rs#L10691-L10697 As its doc comment explains, the function was a stopgap: it guarded callers that were not yet `PathStyle`-aware from receiving a `PathStyle`-constructed path and processing it with `std::path` methods, which produces incorrect results for foreign path styles. Since then, the worktree path handling has largely been migrated to `PathStyle`. The only remaining non-aware consumer in these call chains was `Worktree::directory_name` in `crates/git/src/repository.rs`. This PR removes `repo_identity_path_if_local` and replaces its uses with `repo_identity_path`. `Worktree::directory_name` now takes a `PathStyle`, so the guard is no longer needed. The removal also improves path handling for remote projects, where the path style can differ from the host's. ## Testing Added tests for `RepositorySnapshot::linked_worktree_anchor_path` and `Worktree::directory_name`, covering both Unix and Windows path styles. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [ ] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - N/A |
||
|
|
fae4b2ea4f |
workspace: Fix local file opens with remote workspaces (#65771)
## Summary Closes #58773 While working on this, I noticed that project grouping and workspace lookup used different connection comparisons. I unified them around the existing `RemoteConnectionIdentity`. I also simplified the relevant code, removing redundant lookup and comparison helpers and borrowing values instead of cloning them when the caller only needs to read the data. ## Testing Added corresponding test coverage ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Fixed local files opening as empty buffers in remote workspaces. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev> |
||
|
|
3c2f782514 |
git_panel: Add error treatment when trying to push from an outdated branch (#47296)
When I uploaded to a remote branch with newer commits on my work the push failed and I had no idea why until I used Git through CLI, so I enhanced the UX so no one needs to go through this anymore. Release Notes: - Improved git panel treatment error, previously if you pushed from an outdated branch, it logged a generic message and offered no solution, now it shows an specific message with a button that allows you to solve your issue by fetching, pulling and pushing. Co-authored-by: Lukas Wirth <lukas@zed.dev> |
||
|
|
fdc1005e71 |
Fix worktree creation on Windows remote from Unix host (#63075)
# Objective Closes #63067 Another issue with path handling when connecting from Unix to a Windows remote, similar to #62038. When we create a git worktree from Zed's title bar, Zed computes the target path using many standard library `Path` APIs, such as `Path::file_name()`, `Path::parent()`, and `Path::starts_with()`. All of these methods are platform-dependent. Since we build the Windows path on a Unix client, these methods don't work as intended, which introduces errors. ## Solution This PR does two things. First, it fixes the worktree creation issue. The main change is replacing the standard `Path` APIs with the corresponding ones in `PathStyle` across the methods involved in the worktree path computation chain, mainly `RepositorySnapshot::main_worktree_abs_path()`, `Repository::path_for_new_linked_worktree()`, and `worktrees_directory_for_repo`. This lets us build correct worktree paths on Windows. Additionally, to make the logic testable, the core of `Repository::path_for_new_linked_worktree()` was moved to `RepositorySnapshot`. Second, it fixes the worktree display. The main change is in the `linked_worktree_short_name` function; the rest updates its callers, including the title bar, sidebar, and the agent thread UI. ## Testing Added new tests, and also built and tested locally; a video recording is attached. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed worktree cannot be created when remote connecting from unix system to windows. |
||
|
|
af431aeef4 |
ui: Add buttons to switch diff view when diffing buffers (#64529)
# Objective - This PR enables users to switch between unified/split diff views when comparing buffers. - Fixes #64419 . ## Solution - The unified/split toggle (`DiffStyleControls`) is normally surfaced automatically by `BufferSearchBar`, which detects any active item exposing a `SplittableEditor`. That auto-detection is gated to multi-buffer views, since it's paired with an expand/collapse-all-hunks control that only makes sense across multiple files. `FileDiffView` (used by `zed --diff <old> <new>`) is a singleton buffer, so it's intentionally excluded from that generic path. - Git's own single-file diff view, [`SoloDiffView`](https://github.com/zed-industries/zed/blob/395def7a067b32ed598fcb3f048969ada9b54942/crates/git_ui/src/solo_diff_view.rs#L52), hits the same limitation and works around it with a small, dedicated `ToolbarItemView` (`SoloDiffStyleToolbar`) that renders `DiffStyleControls` directly, independent of `BufferSearchBar`. - This PR follows the same pattern: a new `FileDiffStyleToolbar` (in `git_ui_core::file_diff_view`) activates whenever a `FileDiffView` is the focused pane item, and renders just the unified/split toggle, no expand/collapse or file-status controls, since neither concept applies to a plain two-file diff. It's registered in `initialize_pane` alongside the existing git toolbars. ## Testing - Did you test these changes? If so, how? Ran `cargo test -p git_ui_core`, all passed. I've also attached the results of manual testing in the Showcase section below. - Are there any parts that need more testing? I think more tests can be added. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase Adds a unified/split toggle to the diff view opened via `zed --diff <old> <new>`, matching the toggle already available in git's diff views. <details> <summary>Click to view before/after</summary> **Before**: <img width="1920" height="1080" alt="screenshot_20260921_020610" src="https://github.com/user-attachments/assets/92cbcf75-0cac-4555-8d2d-ce927064515f" /> **After**: <img width="1920" height="1080" alt="screenshot_20260921_020355" src="https://github.com/user-attachments/assets/56f9ebc6-11df-41cc-a44d-99bfa8caa130" /> </details> --- Release Notes: - Added a unified/split toggle to the diff view opened via `zed --diff <old> <new>` command. --------- Co-authored-by: Kirill Bulatov <mail4score@gmail.com> Co-authored-by: Kirill Bulatov <kirill@zed.dev> |
||
|
|
aec7395e30 |
Fix cargo shear warnings (#64340)
Also updates CI to always run this - that way we ensure that disabling or enabling tests does not become stale at some point and thus can safely add this. Release Notes: - N/A - [GPUI] N/A |
||
|
|
5bdfa7c8ab |
ui: Fix modifier key hints on macOS (#63807)
# Objective Fixes #63805 ## Solution change alt -> option! ## Testing I built it and saw. ## Self-Review Checklist: - [y] I've reviewed my own diff for quality, security, and reliability - [y] Unsafe blocks (if any) have justifying comments - [y] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [n] Tests cover the new/changed behavior (no behavior change) - [y] Performance impact has been considered and is acceptable ## Showcase <img width="258" height="52" alt="image" src="https://github.com/user-attachments/assets/73c215d2-dbf6-4eb7-9a96-7ef082d2be8d" /> --- Release Notes: - Fixed hints for branch and worktree deletion, keybinding conflicts, and edit predictions referring to Alt instead of Option on macOS. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> |
||
|
|
229450844d |
git: Move diff hunk operations onto buffer diffs (#63556)
# Objective Keep Git-specific diff-base knowledge in `GitStore`, where Git operations are defined. Related to FR-135. ## Solution Give each `BufferDiff` its supported hunk operations. Keep editor hooks limited to rendering custom controls. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - N/A |
||
|
|
a3f6b96ced |
Avoid redundant string allocations (#63377)
Remove unnecessary intermediate `String` allocations when constructing `Arc<str>` and `SharedString` values. Use static `SharedString` storage for fixed worktree picker identifiers. Validation: - `cargo fmt --all -- --check` - `tooling/lints/single-lint owned_string_into_shared -p editor -p git_ui_core -p toolchain_selector` - `cargo test -p editor -p git_ui_core -p toolchain_selector` Release Notes: - N/A |
||
|
|
8ee36b682c |
git_ui_core: Fix worktree creation for bare repositories (#63351)
Follow-up https://github.com/zed-industries/zed/pull/55153 Fixes https://github.com/zed-industries/zed/discussions/54553#discussioncomment-17091833 When a repository stores its Git data in `~/work/zed/.bare`, creating a linked worktree from Zed is broken in two visible ways: - Zed creates `random-code` at: ``` ~/work/worktrees/.bare/random-code/.bare ``` instead of: ``` ~/work/worktrees/zed/random-code/zed ``` - Because the checkout ends in `.bare`, Zed displays `.bare` as its worktree name in the title bar, worktree picker, and agent thread sidebar. Every worktree Zed creates from that repository gets the same `.bare` label instead of its generated name. This problem is specific to the path Zed creates. Worktrees using either of these layouts are not malformed: ``` ~/work/worktrees/zed/random-code/zed ~/work/zed/some-worktree ``` https://github.com/zed-industries/zed/pull/55153 introduced repository identities for bare repositories. This PR uses that identity in the remaining worktree naming and creation paths. There are three repository layouts to account for: - In a normal repository, the common Git directory is `~/work/zed/.git`, so Zed derives the main worktree at `~/work/zed`. Existing behavior remains unchanged. - With `~/work/zed/.bare`, Git has no main worktree. A checkout named main is still a linked worktree. Zed now treats `~/work/zed` as the repository identity, creates new worktrees under `~/work/worktrees/zed`, and displays their generated names. - With a bare repository named `~/work/foo.git`, `foo.git` is the repository identity. Its worktree path remains `~/work/worktrees/foo.git/random-code/foo.git`. Zed uses foo.git to derive the worktree name random-code, while displaying the repository itself as foo. Existing malformed worktrees such as `~/work/worktrees/.bare/random-code/.bare` are not moved and may continue to display `.bare`. Broken: <p> <img width="238" height="58" alt="image" src="https://github.com/user-attachments/assets/1504e4d0-c34a-471f-8e76-c5ec062b1d77" /> </p> <p> <img width="274" height="49" alt="image" src="https://github.com/user-attachments/assets/13266ca9-4e64-426c-b03c-e23c924a3597" /> </p> <p> <img width="574" height="85" alt="image" src="https://github.com/user-attachments/assets/0fca58c7-5be7-4d36-9067-066d0b80caf8" /> </p> Release Notes: - Fixed linked worktree names and creation paths for bare Git repositories. |
||
|
|
e3056061d4 |
Render control characters in tab titles and project panel entries (#62875)
# Objective Fixes #62664 File names may contain control characters (`\n`, `\r`, `\t`, …) on most platforms. Zed rendered them verbatim, so a file named `notes\ndraft.md` broke the layout of its tab and of its project panel entry instead of showing a readable name. The same held anywhere else a name reached the screen without going through `Label::single_line`. ## Solution The substitution lives in one shared place, `ui::utils::replace_control_characters`, reached through `Label::single_line`. `\n` keeps rendering as the `⏎` Zed already used, so nothing that renders correctly today changes; every other C0 control character maps onto the Unicode "Control Pictures" block by a single rule (`U+2400 + code point`), giving `␉` for tab and `␍` for carriage return. `DEL` maps to `␡`. C1 controls are left alone, having no equivalent there. Where that is wired in: - **`Label::single_line`** — replaces its previous `\n`-only substitution. The project panel already used it everywhere, including folded directory components, so the panel is fixed by this alone. - **Editor tabs** and the **default `Item::tab_content`**, neither of which called `single_line`. - **Terminal tab titles**, which render through their own `tab_content`. Those titles come from OSC escape sequences, so the control characters in them are attacker-controlled. - **`HighlightedLabel::single_line`**, which never substituted anything — not even `\n`. See below. - **The file finder**, for both the file name and the path. - **Nine `tab_content` overrides in git_ui**, by deleting them. - **`HighlightedMatchWithPaths`**, for both the match label and its paths — it backs the tab switcher and the outline panel, among others. ### `HighlightedLabel` needs its offsets moved, not just its text Its highlight indices are byte offsets, and every stand-in is wider in bytes than the character it replaces, so the offsets have to move with the text. Left alone they index into the middle of a character, and `highlight_ranges` slices the string at exactly those offsets — which panics in release builds too. The constructor's `debug_panic!` does not cover this, since `single_line` runs after construction. So `replace_control_characters_remapping_offsets` substitutes and remaps in one pass, over an old-to-new byte offset table built the way `ensure_uniform_list_compatible_label` does it in `lsp_store`. This also fixes the call sites that already asked for a single line, including the branch picker and the tabular column filter values. ### Deleting the git_ui overrides Nine files replicated the default `Item::tab_content` verbatim except for the colour, hardcoding `selected ? Default : Muted` instead of `params.text_color()`. Deleting them lets those tabs inherit the fixed default, and fixes a second bug along the way: none of them dimmed when the pane lost focus. Titles and icons are unaffected — they come from `tab_content_text` and `tab_icon`, which the default calls. `git_graph.rs` already did it this way. ### Tabular column headers These never went through a `Label` at all: the raw `SharedString` was a child of a `div`. They now display stand-ins, while right-click-copy still yields the real column name. Two notes for reviewers: - Both helpers avoid allocating when there is nothing to replace, so the common path is untouched. The previous `self.label.replace('\n', "⏎")` allocated a `String` on every render for every label — including every visible project panel entry, every frame. - Every stand-in is exactly one character, so character offsets are preserved and the existing `truncate_and_trailoff` math on tab titles stays correct. ## Testing - Unit tests cover both helpers: each control character's substitution, repeated occurrences, multi-byte characters (accents, emoji), the borrow-vs-own behaviour, the preserved character count, C1 passthrough, and — for the remapping — offsets before, at and after a replacement, offsets at and past the end, and the invariant that every remapped offset lands on a character boundary. - Unit tests cover `Label::single_line` and `HighlightedLabel::single_line`, the entry points every call site uses. `highlighted_label.rs` had no tests before. - `cargo test -p ui -p file_finder -p workspace -p project_panel -p git_ui -p git_ui_core -p terminal_view -p tabular_data_preview` passes (774 tests), as do `cargo clippy` and `cargo fmt --check`. - No existing test changes behaviour: tests assert on `tab_content_text`, which is untouched; only rendering paths changed. - Verified manually on macOS (aarch64) — see Showcase. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments — none added - [x] The content adheres to Zed's UI standards - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase A directory holding `report<TAB>table.csv`, `notes<LF>draft.md`, `carriage<CR>return.txt` and a normally named `normal.txt`, all four open as tabs. **Before**  **After**  Three things change: 1. **The `notes<LF>draft.md` tab** is the clearest one. Before, the literal newline splits the tab across two lines — `notes` above `draft.md` — distorting the whole tab bar. After, it stays on one line. 2. **`carriage<CR>return.txt` in the project panel** renders as `carriagereturn.txt` before: the `\r` is completely invisible, so the name reads as one word and there is no way to tell a character is there. After, it renders as `carriage␍return.txt`. 3. **`report<TAB>table.csv`** shows a bare gap before, indistinguishable from a space. After, it renders as `report␉table.csv`. Note that `notes<LF>draft.md` looks the same in the project panel in both shots: that entry already called `single_line`, which already handled `\n`. That is precisely the asymmetry this PR removes. ### File finder Before, the newline also breaks the list itself — the `notes<LF>draft.md` row grows to two lines and overlaps the row beneath it. **Before**  **After**  Searching for `table` exercises the offset remapping, the match falling after the control character: **Before**  **After**  One thing this PR does **not** cover: the breadcrumb below the tab bar still renders the raw tab character, as it goes through a different path. ## Release Notes: - Fixed file names containing control characters, such as tabs and newlines, rendering unreadably in tabs, the project panel, the file finder, the tab switcher and terminal tab titles. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev> |
||
|
|
fdad9186b8 |
git_ui: Dismiss askpass prompts when requests end (#61292)
# Objective Fixes #47623 - When authenticating git commands using a security key through `askpass`. The modal which asks for user presence does not get dismissed even after the git command finishes successfully. ## Solution Add a cancellation task to the `AskPassModal`, which gets dropped when the requested operation completes. This cancellation task then dismisses the modal. ## Testing - I've tried authentication through `askpass` using my own security key. Testing both successful and failed authentication. - I've added tests which confirm that the modal gets dismissed when a task is cancelled, and that the cancellation is triggered when `ask_password` Task gets dropped. Willing to pair on review, message me on Slack. Showcase video left out because it would leak private information. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed authentication prompts not dismissing automatically when using security keys with ssh |
||
|
|
c24358d96c |
deps: Bump pathfinder_simd & fix upcoming rustc warnings (#62170)
While building Zed with nightly rustc I've noticed it doesn't compile because of good old pathfinder_simd. It also emits a bunch of warnings about use of f64 literals where f32 is expected, so I've fixed them - it should make future upgrades more straightforward. |
||
|
|
158c16f51c |
workspace: Choose the replacement workspace inside MultiWorkspace::remove (#62141)
# Objective Follow-up to #62028. When archiving removed a thread's workspace, the replacement was derived from whichever sidebar row sat adjacent to the archived one. Rows are a flat list with project headers as separators, so archiving the oldest thread in a project selected the next project's newest thread and moved the user out of the project they were working in — and when that neighbor was remote, connected to its host just to pick a fallback. # Solution - `MultiWorkspace::remove` now chooses the replacement itself from a `RemovalIntent` (keep the project vs close it): a live workspace in the same project, the project's own roots when kept, the nearest retained neighbor, an adjacent local project, then an empty workspace. The workspaces being removed are excluded from that search in one place instead of five. - Sidebar neighbor selection stays within the entry's project section. - The three archive paths now share one removal orchestration, and the three "open the closed workspace first" helpers collapse into one. # Testing New tests cover: the keep-project fallback, neighbor selection staying inside the project section, and archiving with a mock-remote neighboring project never connecting to it. Each was verified to fail against the previous behavior. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed archiving a thread switching the window to a different project. - Fixed a possible crash when archiving a thread while its window was closing. |
||
|
|
21f16f7b5b |
Speed up cargo build -p zed compilation (#62059)
Splits the crate graph.
Before, the compilation graph: `editor → picker_preview → search →
project_panel → open_path_prompt → recent_projects → title_bar →
collab_ui → zed`
After, the compilation graph: `editor → picker_preview → search →
agent_ui → sidebar → zed`
With sccache disabled and project fully built, `touch
crates/editor/src/editor.rs` and `cargo build -p zed` took time
Before (
|