Closes#7923
This PR fixes root worktree renaming by:
1. Handling the case where `new_path` is the new root name instead of a
relative path from the root.
2. [#20313](https://github.com/zed-industries/zed/pull/20313) added
functionality to watch for root worktree renames made externally, e.g.,
via Finder. This PR avoids relying on that watcher because, when
renaming explicitly from Zed, we can eagerly perform the necessary work
(of course after fs rename) instead of waiting for the watcher to detect
the rename. This prevents UI glitches during renaming root.
Todo:
- [x] Fix wrong abs paths when root is renamed
- [x] Fix explicit scan entry func to handle renamed root dir
- [x] Tests
- [x] Test on Linux
- [x] Tested with single and multipe worktrees
- [x] Tested when single file is root file
Release Notes:
- Fixed an issue where worktree root name couldn't be renamed in project
panel.
- [x] snake case keymap properties
- [x] flatten actions
- [x] keymap migration + notfication
- [x] settings migration + notification
- [x] inline completions -> edit predictions
### future:
- keymap notification doesn't show up on start up, only on keymap save.
this is existing bug in zed, will be addressed in seperate PR.
Release Notes:
- Added a notification for deprecated settings and keymaps, allowing you
to migrate them with a single click. A backup of your existing keymap
and settings will be created in your home directory.
- Modified some keymap actions and settings for consistency.
---------
Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
## Context
I noticed that the project panel `select_next_git_entry` wasn't behaving
correctly. Turns out it was searching in reverse, which caused the
action to select itself or the last entry.
This PR corrects the behavior and adds a unit test that should stop
regressions.
Note: Since select next/prev git entry uses the same function as select
next/prev diagnostic, the test partially works for that as well.
Release Notes:
- Fix bug where `select_next_git_entry` project panel action would only
select a previous entry or the currently selected entry.
---------
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
## Context
While looking through the client crate, I noticed that some of the old
functions and variables were still using gpui::model name that was
deprecated during the gpui3 transition. This PR renames those instances
of model to entity to be more inline with gpui3.
In addition, I also renamed `model` to `entity` in cases found by the
below search terms given by @someone13574
- model = cx.
- model: Entity
- model: &Entity
- OpenedModelHandle
- model.update
- model.upgrade
- model = .*\.root (regex)
- parent_model
- model = cx.new
- cx.spawn(move |model
Release Notes:
- N/A
Previously, editor elements had to listen for mouse_up events to
determine when a click had completed. This meant that they only had
access to modifier keys that were pressed during the mouse_up event.
This led to some incorrect user experiences, such as executing a
ctrl+click if the user pressed ctrl after pressing the mouse button, but
before releasing it.
This change adds a click event handler to EditorElement, and adds a
modifier() method to the ClickEvent, which only includes the modifier
keys that were pressed during both mouse down and mouse up. The code for
handling link clicks has been moved into the click event handler, so
that it's only triggered when the non-multi-cursor modifier was held for
both the mouse down and mouse up events.
Closes#12752, #16074, #17892 (the latter two seem to be duplicates of
the former!)
Release Notes:
- Fixed a bug where pressing ctrl/cmd (or other modifiers) after mouse
down but before mouse up still triggered ctrl/cmd+click behavior (e.g.
"go to definition")
Closes#23383
This PR changes `project_panel::NewSearchInDirectory` to open project
search filtered by the parent directory when triggered on a file, rather
than doing nothing.
Release Notes:
- Improved `project_panel::NewSearchInDirectory` to search the parent
directory when triggered on a file
Closes#19192
1. Changed the drag overlay of entries for better visibility of where to
drop.
2. Folded directories (except for the last folded one) will be
highlighted as drop targets.
3. The delimiter between folded directories prevents the directory
highlight from losing focus and acts as part of the directory to avoid
flickering.
This works just like VS Code does.
[fold-drop.webm](https://github.com/user-attachments/assets/853f7c5e-3492-4f56-9736-6d0e3ef09325)
Release Notes:
- Added precise drag-and-drop for files onto folded directories in the
Project Panel.
---------
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
Closes#15966
This PR adds `Alt/Opt+Click` to expand or collapse a directory and all
its contents.
Context:
The current `expand_entry` scans immediate child subdirectories if they
aren’t loaded, while `expand_all_for_entry` scans the entire subtree.
The latter takes longer, so we wait for it to complete to ensure
accurate results.
For full directory scan, instead of using
`refresh_entries_for_paths(vec![path])`, which requires specifying all
explicit paths to refresh, we use `add_path_prefix_to_scan`, which
eliminates the need to list every path. Both methods internally call
`reload_entries_for_paths`, which invokes `should_scan_directory`. This
determines whether to scan deeper based on a path prefix match between
the given directory and its subdirectories, returning `true` for
`add_path_prefix_to_scan`.
The existing code handles scanning, removing path prefixes after scans
complete, and managing ignored directories.
How it works (Expand):
1. Alt clicking on non-ignored closed directory, expands it and all its
subdirectories, except ignored subdirectories. This helps while working
on mono repos, where you might not want to expand dirs like
`node_modules`, `dist`, etc or git submodules, when you expand any root
dir.
In example, `draft` and `posts` dir are ignored dir.
[expand-1.webm](https://github.com/user-attachments/assets/07d3f724-0757-408f-b349-5beb4ee8440e)
2. Alt clicking on ignored closed directory, expands it and all its
subdirectories. This is when you explicitly want to do it, on dirs like
`node_modules`, `dist`, etc.
In example, `dist` dir is ignored dir.
[expand-2.webm](https://github.com/user-attachments/assets/99e55883-ab1a-4a9c-a0f0-48026991a922)
3. In case of auto folded subdirectories, expand all action will take
precedence over it. That is, it will unfold all the subdirectories
inside clicked dir. This is intentional, as user explicitly wants to
reveal as much content as possible. (This is my personal opinion on how
it should work).
[expand-3.webm](https://github.com/user-attachments/assets/f20b0311-e92a-4e34-b640-1469b0d6fa16)
How it works (Collapse):
1. Alt clicking any opened directory will collapse it and all its
children, whether ignored or not. This is when you want to start from a
fresh state.
2. When auto fold is enabled in settings, collapse action will also fold
all subdirectories that it can fold. This is to bring it back to its
fresh state as mentioned above.
[collapse-1-2.webm](https://github.com/user-attachments/assets/74db6cee-0afa-406b-a9a2-7421083a2c2a)
Future:
- Using keybinding to expand/collapse all for selected entry
- Handle expand/collapse all for folded entry
Todos:
- [x] Expand entries logic
- [x] Handle remote worktree for expand
- [x] Figure out scan complete status
- [x] Move expansion logic to status update event
- [x] Collapse entries logic
- [x] Handle fold/unfold subdirs interaction
- [x] Do not expand git ignored sub-dirs
- [x] Tests
- [x] Test Remote
Release Notes:
- Added Alt/Opt+Click functionality to expand or collapse a directory
and all its contents.
There's still a bit more work to do on this, but this PR is compiling
(with warnings) after eliminating the key types. When the tasks below
are complete, this will be the new narrative for GPUI:
- `Entity<T>` - This replaces `View<T>`/`Model<T>`. It represents a unit
of state, and if `T` implements `Render`, then `Entity<T>` implements
`Element`.
- `&mut App` This replaces `AppContext` and represents the app.
- `&mut Context<T>` This replaces `ModelContext` and derefs to `App`. It
is provided by the framework when updating an entity.
- `&mut Window` Broken out of `&mut WindowContext` which no longer
exists. Every method that once took `&mut WindowContext` now takes `&mut
Window, &mut App` and every method that took `&mut ViewContext<T>` now
takes `&mut Window, &mut Context<T>`
Not pictured here are the two other failed attempts. It's been quite a
month!
Tasks:
- [x] Remove `View`, `ViewContext`, `WindowContext` and thread through
`Window`
- [x] [@cole-miller @mikayla-maki] Redraw window when entities change
- [x] [@cole-miller @mikayla-maki] Get examples and Zed running
- [x] [@cole-miller @mikayla-maki] Fix Zed rendering
- [x] [@mikayla-maki] Fix todo! macros and comments
- [x] Fix a bug where the editor would not be redrawn because of view
caching
- [x] remove publicness window.notify() and replace with
`AppContext::notify`
- [x] remove `observe_new_window_models`, replace with
`observe_new_models` with an optional window
- [x] Fix a bug where the project panel would not be redrawn because of
the wrong refresh() call being used
- [x] Fix the tests
- [x] Fix warnings by eliminating `Window` params or using `_`
- [x] Fix conflicts
- [x] Simplify generic code where possible
- [x] Rename types
- [ ] Update docs
### issues post merge
- [x] Issues switching between normal and insert mode
- [x] Assistant re-rendering failure
- [x] Vim test failures
- [x] Mac build issue
Release Notes:
- N/A
---------
Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Joseph <joseph@zed.dev>
Co-authored-by: max <max@zed.dev>
Co-authored-by: Michael Sloan <michael@zed.dev>
Co-authored-by: Mikayla Maki <mikaylamaki@Mikaylas-MacBook-Pro.local>
Co-authored-by: Mikayla <mikayla.c.maki@gmail.com>
Co-authored-by: joão <joao@zed.dev>
Follow up to https://github.com/zed-industries/zed/pull/22658
This PR ensures the background and border color of a project panel entry
is exactly the same with one exception: if the item is focused, active,
and not with mouse down. The point is to not be able to see the border
at all given they're there to act sort of akin to CSS's `outline` (which
doesn't add up to the box model).
Please let me know if there is any edge case I either messed up here or
didn't account for.
https://github.com/user-attachments/assets/29c74f6a-b027-4d19-a7de-b9614f0d7859
Release Notes:
- N/A
- [x] Basic implementation
- [x] Disable commit buttons when committing is not possible (empty
message, no changes)
- [x] Upgrade GitSummary to efficiently figure out whether there are any
staged changes
- [x] Make CommitAll work
- [x] Surface errors with toasts
- [x] Channel shutdown
- [x] Empty commit message or no changes
- [x] Failed git operations
- [x] Fix added files no longer appearing correctly in the project panel
(GitSummary breakage)
- [x] Fix handling of commit message
Release Notes:
- N/A
---------
Co-authored-by: Nate <nate@zed.dev>
Closes#23216
This crash happens in the `update_visible_entries` function, where we
calculate `ancestors` and `current_ancestor_depth`. `ancestors` is map
storing information about folded ancestors and `current_ancestor_depth`
is basically selected ancestor index in reverse order of visibility.
For example, before adding a new file or directory in `a/b/c`, the
`ancestors` might look like:
```jsonc
{
"entry_id_of_c": {
"current_ancestor_depth": 2, // "a" is selected
"ancestors": ["entry_id_of_a", "entry_id_of_b", "entry_id_of_c"]
}
}
```
When new file or directory is added to`a`, ancestors length is reduced,
as `a` now is not part of folded dir due to having multiple children.
But depth still remains the same as while calculating it, we use depth
from `old_ancestors` to preserve selection across renders. This causes
panic.
```jsonc
{
"entry_id_of_c": {
"current_ancestor_depth": 2, // wrong: use of old depth here causes panic
"ancestors": ["entry_id_of_b", "entry_id_of_c"] // correct: notice "a" is missing, as "a" now has multiple children
}
}
```
This PR fixes it by capping depth so it don't exceed `ancestors` array.
This preserves existing depth as well as handles our edge case.
Release Notes:
- Fixed crash when adding a new file or directory to the first folded
directory
This PR resolves one part of issue #14496
In project panel, when dragging, if you hover over a directory for
~500ms, it now auto-expands so you can drag and drop into nested
directories.
Task cleanup is handled in these cases:
- Dragged onto a different entry.
- Dragged anywhere else, and the 500ms timer runs out (for example, out
of the project panel).
- Dropped onto any entry.
I don’t see any edge cases where task isn’t cleaned up after 500ms.
https://github.com/user-attachments/assets/19da0da1-f9e2-42df-8ee4-fab6dc9a185a
Release Notes:
- Added auto-expand for directories on hover for a while during
dragging.
First, parse the output of `git status --porcelain=v1` into a
representation that can handle the full "grammar" and doesn't lose
information.
Second, as part of pushing this throughout the codebase, expand the use
of the existing `GitSummary` type to all the places where status
propagation is in play (i.e., anywhere we're dealing with a mix of files
and directories), and get rid of the previous `GitSummary ->
GitFileStatus` conversion.
- [x] Synchronize new representation over collab
- [x] Update zed.proto
- [x] Update DB models
- [x] Update `GitSummary` and summarization for the new `FileStatus`
- [x] Fix all tests
- [x] worktree
- [x] collab
- [x] Clean up `FILE_*` constants
- [x] New collab tests to exercise syncing of complex statuses
- [x] Run it locally and make sure it looks good
Release Notes:
- N/A
---------
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
Also:
* Adds `impl_internal_actions!` for deriving the `Action` trait without
registering.
* Removes some deserializers that immediately fail in favor of
`#[serde(skip)]` on fields where they were used. This also omits them
from the schema.
Release Notes:
- Keymap settings file now has more JSON schema information to inform
`json-language-server` completions and info, particularly for actions
that take input.
This makes the `RemoveFromProject` action to remove all marked entries
in the project panel instead of just the selected one.
Closes#22454
Release Notes:
- Improved the `RemoveFromProject` action to remove all selected items.
Closes#22655
A more detailed write-up for this change can be found in the issue
itself. Here, I'm just providing previews after the change. The preview
before the change can be found in the attached issue.
1. While selecting multiple entries, the last clicked entry should be
selected.
[a.webm](https://github.com/user-attachments/assets/2add69c3-82a9-4e45-92e8-366aaf9b298a)
2. When holding `Ctrl`/`Cmd` on an entry, there should be clear visual
feedback to indicate whether the entry is selected or marked.
[b.webm](https://github.com/user-attachments/assets/2cefb8aa-e7d0-4929-9efa-89a4329f428b)
3. When only one entry is marked, but it’s different from the selection,
operations should prioritize the selected entry. This let's you do quick
one-off actions without disrupting the marked state.
[c.webm](https://github.com/user-attachments/assets/8e7ae0c0-4387-49b9-9761-5d02a1c21a84)
4. When more than one entries are marked, operations should prioritize
the marked entries. If the selection differs from the marked entries, it
should not interfere with operations on the marked entries. This let's
you do actions on multiple marked entries without needing to adjust the
selection.
[d.webm](https://github.com/user-attachments/assets/165a74be-cbe9-48ac-b558-2562485ea224)
Release Notes:
- Improved project panel selection, copying, and deletion behavior, to
be more predictable.
The existing code was causing us to constantly re-scan files when
anything changed in the project. Temporarily revert this as we're about
to rework this entire UI with the new primitives.
follow up to https://github.com/zed-industries/zed/pull/22329
Release Notes:
- N/A
---------
Co-authored-by: Cole <cole@zed.dev>
- [x] Rewrite worktree git handling
- [x] Fix tests
- [x] Fix `test_propagate_statuses_for_repos_under_project`
- [x] Replace `WorkDirectoryEntry` with `WorkDirectory` in
`RepositoryEntry`
- [x] Add a worktree event for capturing git status changes
- [x] Confirm that the local repositories are correctly updating the new
WorkDirectory field
- [x] Implement the git statuses query as a join when pulling entries
out of worktree
- [x] Use this new join to implement the project panel and outline
panel.
- [x] Synchronize git statuses over the wire for collab and remote dev
(use the existing `worktree_repository_statuses` table, adjust as
needed)
- [x] Only send changed statuses to collab
Release Notes:
- N/A
---------
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.com>
Co-authored-by: Nathan <nathan@zed.dev>
Closes#19974.
When a file is pasted in the project panel at a location where a file
with that name already exists, the new file's name is disambiguated by
appending " copy" at the end. This happens on the paste and the
duplicate actions, as well as when Alt-dragging files.
With this PR, this will now open the file rename editor with the
disambiguator pre-selected.
Open question:
With this PR's current implementation, this won't always work when
pasting multiple files at once. In this case, the file rename editor
only opens for the last pasted file, if that file was disambiguated. If
only other files were disambiguated instead, it won't open.
This roughly mimics the previous paste behaviour, namely that only the
last pasted file was selected.
I see two options here: If multiple files were pasted and some of them
were disambiguated, we could select and open the rename editor for the
last file that was actually disambiguated (easy), or we could open a
kind of multi-editor for all files (hard, but maybe a multi-rename
editor could actually be interesting in general...).
Release Notes:
- Open rename file editor if pasted file was disambiguated
This means that `workspace::ToggleRightDock` will open the assistant if
no right-dock panel has been manually activated, instead of the chat as
before. Also cleans up the `active_panel_index` logic a bit.
cc @nathansobo
Release Notes:
- Make `workspace::ToggleRightDock` open the assistant panel if no
right-dock panel has yet been activated
* Remove unnecessary WindowContext and ViewContext '_ lifetimes
* Removed some cases where WindowContext has a different name than `cx`.
Release Notes:
- N/A
No issue attached, as this is something trivial and should have been
part of my merged PR
[here](https://github.com/zed-industries/zed/pull/22073).
For context, in the above-mentioned PR, I removed the hover color from
selected/marked entries in the Project Panel. The reasoning behind this
change is already explained in that PR, but to reiterate:
> This change was inspired by the behavior in VSCode, the Firefox
sidebar, and Dolphin (KDE File Manager). When an item is selected, it
doesn’t display a separate hover state to avoid confusing users about
whether the item is selected or merely hovered over.
@nilskch mentioned in the comments of the above PR that I should have
also changed the background of the knockout icon, which appears on
entries, to match the entry background color on hover. This PR addresses
that.
Before:

After:

Release Notes:
- N/A
Closes#22072
Clicking on the remaining space now allows a single click to deselect
all selected items. Check the issue for a preview of the current state
and how it works in VSCode.
Bonus: I found the hover color on selected items to be distracting. When
I have many entries selected and hover over them, it becomes hard to
tell if a particular entry is selected while the mouse pointer is on it.
This PR removes hover coloring for selected entries, mimicking how
VSCode handles it.
This PR:
<img
src="https://github.com/user-attachments/assets/9c4b20fc-df93-4868-b7fe-4045433e85b2"
alt="zed" width="450px" />
Release Notes:
- Clicking on empty space in the Project Panel now deselects all
selected items.
This PR updates the `gpui::prelude` to not export the `Context` trait
named.
This prevents some naming clashes in downstream consumers.
Release Notes:
- N/A
Closes#21605
Consider you have set of entries selected or even a single entry
selected, and you right click some other entry which is **not** part of
your selected set. This doesn't not clear existing entries selection
(which it should clear, as how file manager right-click logic works, see
more below).
This issue might lead unexpected operation like deletion applied on
those existing selected entries. This PR fixes it.
Release Notes:
- Fix right click selection behavior in project panel
Closes#21266
Release Notes:
- Fixes not using the `panel.background` color in the file tree
See comments in https://github.com/zed-industries/zed/issues/21266 for
more details.
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Part of https://github.com/zed-industries/zed/issues/20925
This prototype is behind a feature flag and being merged to avoid
conflicts with further git-related resturctures.
To be a proper, public feature, this needs at least:
* showing deleted files
* better performance
* randomized tests
* `TODO`s in the `project_diff.rs` file fixed
The good thing is, >90% of the changes are in the `project_diff.rs` file
only, have a basic test and already work on simple cases.
Release Notes:
- N/A
---------
Co-authored-by: Thorsten Ball <thorsten@zed.dev>
Co-authored-by: Cole Miller <cole@zed.dev>
Closes https://github.com/zed-industries/zed/issues/12029
Allows to introspect project items inside items more deeply, checking
them for being dirty.
For that:
* renames `project::Item` into `project::ProjectItem`
* adds an `is_dirty(&self) -> bool` method to the renamed trait
* changes the closing logic to only care about dirty project items when
checking for save prompts conditions
* save prompts are raised only if the item is singleton without a
project path; or if the item has dirty project items that are not open
elsewhere
Release Notes:
- Fixed item closing overly triggering save dialogues
Closes#20845
I'm uncertain about my placement for the logic to remove actions from
the command palette list. If anyone has insights or alternative
approaches, I'm open to changing the code.
Release Notes:
- Removed project panel `Trash` action for remote projects.
---------
Co-authored-by: Finn Evers <dev@bahn.sh>
Closes#20858
This fix depends on the sanitization logic implemented in PR #20577.
Since that branch may undergo further changes, this branch will be
periodically rebased on it. Once #20577 is merged, the dependency will
no longer apply.
Release Notes:
- Fix missing or duplicated files when copying multiple items in the
project panel.
- Fix marked files not being deselected after selecting a directory on
primary click.
- Fix "copy path" and "copy path relative" with multiple items selected
in project panel.
**Problem**:
In this case, `dir1` is selected while `dir2`, `dir3`, and `dir1/file`
are marked. Using the `marked_entries` function results in only `dir1`,
which is incorrect.
<img height="120"
src="https://github.com/user-attachments/assets/d4d92cc5-c998-4948-9a58-25c4f54167f2"
/>
Currently, the `marked_entries` function is used in five actions, which
all produce incorrect results:
1. Delete (via the disjoint function)
2. Copy
3. Cut
4. Copy Path
5. Copy Path Relative
**Solution**:
1. `marked_entries` function should not use "When currently selected
entry is not marked, it's treated as the only marked entry." logic.
There is no grand scheme behind this logic as confirmed by piotr
[here](https://github.com/zed-industries/zed/issues/17746#issuecomment-2464765963).
2. `copy` and `cut` actions should use the disjoint function to prevent
obivous failures.
3. `copy path` and `copy path relative` should keep using *fixed*
`marked_entries` as that is expected behavior for these actions.
---
1. Before/After: Partial Copy
Select `dir1` and `c.txt` (in that order, reverse order works!), and
copy it and paste in `dir2`. `c.txt` is not copied in `dir2`.
<img height="170"
src="https://github.com/user-attachments/assets/a09fcb40-f38f-46ef-b0b4-e44ec01dda18"
/>
<img height="170"
src="https://github.com/user-attachments/assets/bb87dbe5-8e2e-4ca4-a565-42be5755ec8a"
/>
---
2. Before/After: Duplicate Copy
Select `a.txt`, `dir1` and `c.txt` (in that order), and copy it and
paste in `dir2`. `a.txt` is duplicated in `dir2`.
<img height="170"
src="https://github.com/user-attachments/assets/6f999d22-3607-48d7-9ff6-2e27494002f8"
/>
<img height="170"
src="https://github.com/user-attachments/assets/b4b6ff7d-0df7-45ea-83e4-50a0acb18457"
/>
---
3. Before/After: Directory Selection
Simply primary click on any file, now primary click on any dir. That
previous file is still marked.
<img height="170"
src="https://github.com/user-attachments/assets/9f1948ce-7445-4377-9733-06490ed6a324"
/>
<img height="170"
src="https://github.com/user-attachments/assets/e78203bc-96ba-424b-b588-c038992a9f0e"
/>
---
4. Before/After: Copy Path and Copy Path Relative
Upon `copy path` (ctrl + alt + c):
Before: Only `/home/tims/test/dir2/a.txt` was copied.
After: All three paths `/home/tims/test/dir2`, `/home/tims/test/c.txt`
and `/home/tims/test/dir2/a.txt` are copied.
This is also how VSCode also copies path when multiple are selected.
<img height="170"
src="https://github.com/user-attachments/assets/e20423ea-1682-4efd-b208-631e2edd3771"
/>
Closes#20444
- Focus on next file/dir on deletion.
- Focus on prev file/dir in case where it's last item in worktree.
- Tested when multiple files/dirs are being deleted.
Release Notes:
- Maintain selection on file/dir deletion in project panel.
---------
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Closes#4745
Release Notes:
- Added a new `file_scan_inclusions` setting to force Zed to index files
that match the provided globs, even if they're gitignored.
---------
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This PR introduces a new parameter for `on_drag` in gpui, which is an
offset from the element origin to the mouse event origin.
Release Notes:
- Fixed rendering of dragged project panel entries