Commit graph

548 commits

Author SHA1 Message Date
Cole Miller
1763dd714b
Worktree paths in git panel, take 2 (#26047)
Modified version of #25950. We still use worktree paths, but repo paths
with a status that lie outside the worktree are not excluded; instead,
we relativize them by adding `..`. This makes the list in the git panel
match what you'd get from running `git status` (with the repo's worktree
root as the working directory).

- [x] Implement + test new unrelativization logic
- [x] ~~When collecting repositories, dedup by .git abs path, so
worktrees can share a repo at the project level~~ dedup repos at the
repository selector layer, with repos coming from larger worktrees being
preferred
- [x] Open single-file worktree with diff when activating a path not in
the worktree

Release Notes:

- N/A
2025-03-06 22:55:28 +00:00
smit
593f3dc1d5
keymap: Update Prev to Previous for consistency (#25909)
Closes #10167

This is take 2 on https://github.com/zed-industries/zed/pull/2341 which
was closed due to lack of migrator.

This PR contains rename of following keymap actions: 
```sh
1. ["editor::GoToPrevHunk", { "center_cursor": true }] -> ["editor::GoToPreviousHunk", { "center_cursor": true }]
2. "editor::GoToPrevDiagnostic" -> "editor::GoToPreviousDiagnostic"
3. "editor::ContextMenuPrev" -> "editor::ContextMenuPrevious"
4. "search::SelectPrevMatch" -> "search::SelectPreviousMatch"
5. "file_finder::SelectPrev" -> "file_finder::SelectPrevious"
6. "menu::SelectPrev" -> "menu::SelectPrevious"
7. "editor::TabPrev" -> "editor::Backtab"
```

Release Notes:

- Renamed several keymap actions for consistency (e.g., `GoToPrevHunk` →
`GoToPreviousHunk`, `TabPrev` → `Backtab`). Your existing configured
keybindings will still work. You can click **"Backup and Update"** at
the top of your keymap file to easily update to the new actions.


Co-authored-by: Joseph T. Lyons <JosephTLyons@gmail.com>
2025-03-03 17:44:49 +05:30
Cole Miller
7a34dd9888
Save buffers after restoring hunks in the project diff (#25620)
This PR fixes a bug where using the project diff editor to restore hunks
from a file that's not open in its own buffer would cause those reverts
to be lost once the project diff drops its excerpts for that file.

The fix is to save the buffers after restoring them but before the
excerpts are (potentially) dropped. This is done for the project diff
editor only. If we fail to save the affected files, we add their buffers
to the active workspace, so that the reverted contents are preserved and
the user can try again to save them.

- [x] Get it working
- [x] Test
- [ ] ~~Clean up boolean soup~~

Co-authored-by: Max <max@zed.dev>

Release Notes:

- N/A
2025-02-26 15:16:17 -05:00
Peter Tripp
eebee4ab18
Add stop_at_indent for MoveToBeginningOfLine (#25428)
Add support for `stop_at_indent` option for MoveToBeginningOfLine and SelectToBeginningOfLine instead of mixing that with `stop_at_soft_wraps`.
Add emacs mapping for `alt-m` (`back-to-indentation`)
2025-02-25 12:03:14 -05:00
smit
524e813d20
project_panel: Fix entry not being marked when triggered via keyboard (#25567)
This is follow-up for https://github.com/zed-industries/zed/pull/25457

If you open a project without any open buffer, focus on the project
panel, navigate with arrows to a given entry, and hit space, you will
mark and open the file in the buffer. This is all correct. If you then
hit `escape` to clear the marked entries, nothing happens to the open
buffer, and the marked styled in the project panel entry go away. This
is all correct. The wrong behavior happens if you now hit space again on
the active entry. That should mark it, and thus change its styles, but
it doesn't happen. You just see it upon moving to a different entry with
arrow up/down.

Release Notes:

- Fixed project panel entry not being marked when triggering open action
via keyboard.

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2025-02-25 21:24:13 +05:30
smit
796e87ecbc
project_panel: Open file in editor on paste action when single entry (#25555)
Closes #25145

Now, upon pasting a file into the project panel after a copy or cut
operation, it will open in the editor. This buffer in the editor will be
in focus if there is no need to rename the newly pasted file. If a
rename is pending, it simply focuses on the rename editor.


https://github.com/user-attachments/assets/563b22ec-d1f6-4d92-af18-29d10620832c


Future: After the rename is completed, we can decide to focus on the
editor buffer, but this will be addressed in a follow-up, as there will
be multiple cases, such as renaming via a paste action where we want to
focus, and renaming directly via a rename action where we might not want
to focus.

Release Notes:

- Fixed scenario where pasting a file in the project panel after a
copy/cut operation wouldn't automatically open it in the editor.
2025-02-25 16:39:16 +05:30
Cole Miller
e06666759a
Improve performance of project panel with many git statuses (#25465)
Closes #ISSUE

Release Notes:

- Improved performance of project panel in large git repositories
2025-02-24 17:03:52 -05:00
Danilo Leal
fc8218d728
project panel: Change marked entries behavior and improve state colors (#25457)
Follow up to @0xtimsb's PR
https://github.com/zed-industries/zed/pull/22658.

- We're now changing the marked entry as we change the active buffer via
the pane tabs. If all tabs are closed, we clear all marked entries, too.
That means: if we have no open buffer, we don't have any highlighted
entry (i.e., background color) in the project panel.
- Also, now only marked entries have a different, more distinct
background color. The `is_active` state doesn't change an item's
background color anymore.
- This improves an edge case where you could have multiple entries
marked—where all of them would have a background color—and upon
unmarking one of them, that entry would continue to have a bg color.
Now, once you click or move your focus to unmark that entry, the bg
color goes away.

We discovered some new problems by doing these changes that we want to
fix:
1. If you open a project without any open buffer, focus on the project
panel, navigate with arrows to a given entry, and hit space, you will
mark and open the file in the buffer. This is all correct. If you then
hit `escape` to clear the marked entries, nothing happens to the open
buffer, and the marked styled in the project panel entry go away. This
is all correct. The wrong behavior happens if you now hit space _again_
on the active entry. That should mark it, and thus change its styles,
but it doesn't happen. You just see it upon moving to a different entry
with arrow up/down.
2. If you mark multiple entries on the project panel and then click on
an open buffer, we still see all the multiple entries marked. This feels
incorrect. We should only allow one marked entry at a time.

These fixes should happen in follow up PRs, though.

Release Notes:

- Improved the scenario where there'd be a project panel entry
highlighted/marked even if there is no open buffer.

---------

Co-authored-by: smit <0xtimsb@gmail.com>
2025-02-24 22:44:09 +05:30
PJ Tatlow
b6fd06d63c
project_panel: Make scroll to bottom to use the last visible entry (#25160)
Closes #25159

Release Notes:

- Fixed project panel implementation of the `menu::SelectLast` action
2025-02-19 16:00:23 +00:00
Michael Sloan
b1872e3afd
cx.background_executor().spawn(...) -> cx.background_spawn(...) (#25103)
Done automatically with

> ast-grep -p '$A.background_executor().spawn($B)' -r
'$A.background_spawn($B)' --update-all --globs "\!crates/gpui"

Followed by:

* `cargo fmt`
* Unexpected need to remove some trailing whitespace.
* Manually adding imports of `gpui::{AppContext as _}` which provides
`background_spawn`
* Added `AppContext as _` to existing use of `AppContext`

Release Notes:

- N/A
2025-02-18 20:30:33 +00:00
Dino
e0fc767c11
Display case-sensitive keybindings for vim commands (#24322)
This Pull Request tackles the issue outline in #14287 by changing the
way `KeyBinding`s for vim mode are displayed in the command palette.
It's worth pointing out that this whole thing was pretty much
implemented by Conrad Irwin during a pairing session, I just tried to
clean up some other changes introduced for a different issue, while
improving some comments.

Here's a quick list of the changes introduced:

- Update `KeyBinding` with a new `vim_mode` field to determine whether
the keybinding should be displayed in vim mode.
- Update the way `KeyBinding` is rendered, so as to detect if the
keybinding is for vim mode, if it is, only display keys in uppercase if
they require the shift key.
- Introduce a new global state – `VimStyle(bool)` - use to determine
whether `vim_mode` should be enabled or disabled when creating a new
`KeyBinding` struct. This global state is automatically set by the `vim`
crate whenever vim mode is enabled or disabled.
- Since the app's context is now required when building a `KeyBinding` ,
update a lot of callers to correctly pass this context.

And before and after screenshots, for comparison:

| before | after |
|--------|-------|
| <img width="1050" alt="SCR-20250205-tyeq"
src="https://github.com/user-attachments/assets/e577206d-2a3d-4e06-a96f-a98899cc15c0"
/> | <img width="1050" alt="SCR-20250205-tylh"
src="https://github.com/user-attachments/assets/ebbf70a9-e838-4d32-aee5-0ffde94d65fb"
/> |

Closes #14287 

Release Notes:

- Fix rendering of vim commands to preserve case sensitivity

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-02-14 22:03:59 -07:00
Marshall Bowers
e60123bbdc
Allow icon themes to provide their own file associations (#24926)
This PR adds the ability for icon themes to provide their own file
associations.

The old `file_types.json` that was previously used to make these
associations has been removed in favor of storing them on the default
theme.

Icon themes have two new fields on them:

- `file_stems`: A mapping of file stems to icon keys.
- `file_suffixes`: A mapping of file suffixes to icon keys.

These mappings produce icon keys which can then be used in `file_icons`
to associate them to a particular icon:

```json
{
  "file_stems": {
    "Makefile": "make"
  },
  "file_suffixes": {
    "idr": "idris"
  },
  "file_icons": {
    "idris": { "path": "./icons/idris.svg" },
    "make": { "path": "./icons/make.svg" }
  }
}
```

When loading an icon theme, the `file_stems` and `file_icons` fields
will be merged with the ones from the base icon theme, with the values
from the icon theme being loaded overriding ones in the base theme.

Release Notes:

- Added the ability for icon themes to provide their own file
associations.
2025-02-15 00:35:13 +00:00
Piotr Osiewicz
a618830aea
project: Fine-grained language server management (#24038)
Closes #ISSUE
https://github.com/zed-industries/zed/pull/23804
Release Notes:

- Improved detection of project roots for use by language servers.

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: smit <0xtimsb@gmail.com>
Co-authored-by: Henrikh Kantuni <henrikh.kantuni@gmail.com>
Co-authored-by: Caleb! <48127194+kaf-lamed-beyt@users.noreply.github.com>
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Co-authored-by: Agus Zubiaga <agus@zed.dev>
Co-authored-by: Danilo <danilo@zed.dev>
Co-authored-by: Nate Butler <iamnbutler@gmail.com>
2025-02-14 15:41:49 +01:00
Mikayla Maki
5d26ce14d7
Centralize the CopyPath and CopyRelativePath actions to zed_actions (#24836)
I spent an hour with @marcospb19 this morning debugging an issue with
adding `Copy Path` and `Copy Relative Path` actions to the editor
context menu. Turned out that the problem was using
`workspace::CopyPath` in the menu and `editor::CopyPath` in the action
handler.

This is an easy mistake to make, so let's fix it for everyone.

Release Notes:

- N/A
2025-02-13 23:30:44 +00:00
Conrad Irwin
2f741c8686
vim: Fix :wq in multibuffer (#24603)
Supercedes #24561
Closes #21059

Before this change we would skip saving multibuffers regardless of the
save intent. Now we correctly save them.

Along the way:
* Prompt to save when closing the last singleton copy of an item (even
if it's still open in a multibuffer).
* Update our file name prompt to pull out dirty project items from
multibuffers instead of counting multibuffers as untitled files.
* Fix our prompt test helpers to require passing the button name instead
of the index. A few tests were passing invalid responses to save
prompts.
* Refactor the code a bit to hopefully clarify it for the next bug.

Release Notes:

- Fixed edge-cases when closing multiple items including multibuffers.
Previously no prompt was generated when closing an item that was open in
a multibuffer, now you will be prompted.
- vim: Fix :wq in a multibuffer
2025-02-13 17:13:43 +00:00
Nate Butler
2d71733490
ui: Update Label component (#24653)
- Standardize style methods
- Convert label story to a component preview
- update component preview styles  

Release Notes:

- N/A
2025-02-11 20:16:59 +00:00
smit
f1693e6129
project_panel: Fix worktree root rename (#24487)
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.
2025-02-09 14:16:27 +05:30
smit
00c2a30059
Migrate keymap and settings + edit predictions rename (#23834)
- [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>
2025-02-07 21:17:07 +05:30
Anthony Eid
d83c316e6d
Fix Project Panel select_next_git_entry action (#24217)
## 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>
2025-02-07 03:04:02 +00:00
张小白
74c4dbd237
windows: Fix tests on Windows (#22616)
Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla.c.maki@gmail.com>
2025-02-05 14:30:09 +00:00
Anthony Eid
8c7096f7a6
Rename model based variable names to entity (#24198)
## 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
2025-02-04 10:24:35 -08:00
Shane Friedman
c28a4204ee
Use click event to determine modifier keys (#22988)
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")
2025-01-30 16:40:20 -08:00
William Blazer
ff72c6358e
Fix project_panel::NewSearchInDirectory to work on files (#23696)
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
2025-01-29 22:50:12 +00:00
tims
f314662048
project_panel: Add precise drag-and-drop for files onto folded directories (#22983)
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>
2025-01-28 10:42:10 +02:00
tims
5c650cdcb2
project_panel: Add Alt/Opt+Click to expand/collapse a directory and all its contents (#22896)
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.
2025-01-28 10:37:56 +02:00
Mikayla Maki
9cae96f82f
Remove more references to 'model' in GPUI APIs (#23693)
Release Notes:

- N/A
2025-01-27 04:00:27 +00:00
Nathan Sobo
6fca1d2b0b
Eliminate GPUI View, ViewContext, and WindowContext types (#22632)
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>
2025-01-26 03:02:45 +00:00
Danilo Leal
d011b97830
project_panel: Adjust entry background and border colors (#23403)
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
2025-01-21 11:13:46 -03:00
Cole Miller
5da67899b7
git: Implement commit creation (#23263)
- [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>
2025-01-17 18:51:20 +00:00
Piotr Osiewicz
c9534e8025
chore: Use workspace fields for edition and publish (#23291)
This prepares us for an upcoming bump to Rust 2024 edition.

Release Notes:

- N/A
2025-01-17 17:39:22 +01:00
tims
b1375ab946
project_panel: Fix crash when adding a new file or directory to the first folded directory (#23217)
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
2025-01-16 23:34:44 -07:00
tims
21e7765a48
project_panel: Add directory auto-expand after 500ms hover during dragging (#23080)
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.
2025-01-16 20:54:37 -07:00
Cole Miller
a41d72ee81
Represent git statuses more faithfully (#23082)
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>
2025-01-16 00:01:38 +00:00
Marshall Bowers
72f1b32cc5
project_panel: Remove useless comments (#23186)
This PR removes some comments in the `project_panel` that are just
restating what the code is doing.

Release Notes:

- N/A
2025-01-15 17:20:36 +00:00
Michael Sloan
6aba3950d2
Improve keymap json schema (#23044)
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.
2025-01-13 02:34:35 +00:00
Mike Sun
9ea7ed8e0a
Allow configuring spacing of project panel entries (#16255)
Release Notes:

- Added `project_panel.entry_spacing` setting to configure spacing
between entries in the project panel.

### Comfortable (default)
```json
  "project_panel": {
    "entry_spacing": "comfortable",
```
<img width="1582" alt="Screenshot 2024-08-14 at 5 50 41 PM"
src="https://github.com/user-attachments/assets/3411a82e-7517-4095-bf4a-bbf40000a7cb">

### Standard
```json
  "project_panel": {
    "entry_spacing": "standard",
```
<img width="1582" alt="Screenshot 2024-08-14 at 5 50 54 PM"
src="https://github.com/user-attachments/assets/2c13d799-c405-4301-8214-1cb3cc641c92">

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2025-01-09 17:57:52 +00:00
Sergei Shulepov
56017022c4
project_panel: Support multiple items in RemoveFromProject (#22455)
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.
2025-01-07 17:25:33 +00:00
tims
6fce53651b
project_panel: Refine selection, copying, and deletion behavior (#22658)
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.
2025-01-07 00:46:50 +00:00
Mikayla Maki
3c430af31a
Temporarily revert git panel diff editor feature (#22733)
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>
2025-01-06 22:09:05 +00:00
Mikayla Maki
9613084f59
Move git status out of Entry (#22224)
- [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>
2025-01-04 01:00:16 +00:00
Josef Zoller
8cb397cf6c
project_panel: Open rename file editor if pasted file was disambiguated (#19975)
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
2025-01-02 21:33:51 +00:00
Cole Miller
dcbff982ad
Decide which panel should be active for a dock based on ordering panels (#22346)
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
2024-12-30 14:43:17 +00:00
Michael Sloan
a15360bcc8
Dequalify WindowContext and ViewContext references (#22477)
Release Notes:

- N/A
2024-12-28 23:09:55 +00:00
Michael Sloan
016b5d60e1
Cleanups preparing for WindowContext refactor (#22475)
* Remove unnecessary WindowContext and ViewContext '_ lifetimes

* Removed some cases where WindowContext has a different name than `cx`.

Release Notes:

- N/A
2024-12-28 21:36:14 +00:00
tims
306fc19739
Fix knockout icon background to match hovered entry background in project panel (#22258)
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:

![Screenshot_20241219_230005](https://github.com/user-attachments/assets/fd517e01-1a1e-4e63-9320-ba24bf3d4c64)

After:

![Screenshot_20241219_225853](https://github.com/user-attachments/assets/35fb146f-83e4-409b-8061-0efbdbba5cf9)

Release Notes:

- N/A
2024-12-20 21:24:38 +00:00
Michael Sloan
fc5a810408
Add Corner to geometry and make names of corner methods consistent (#22119)
Release Notes:

- N/A
2024-12-16 22:57:15 -07:00
tims
62b3acee5f
Project panel: Deselect entries on remaining blank space click + Remove hover color for selected entries (#22073)
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.
2024-12-16 14:05:54 +01:00
Bennet Bo Fenner
636c28b652
project panel: Reintroduce project panel knockout color (#21926)
Reintroduces #20760 after it was reverted in #21807

Closes #20572

/cc @danilo-leal 

Release Notes:

- N/A

---------

Co-authored-by: Cole <cole@zed.dev>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
2024-12-13 00:52:03 -03:00
CharlesChen0823
241b14eeaf
project_panel: Create items when the editor is dismissed via the mouse (#21045)
Closes #5036 

Release Notes:

- Created project panel items when the editor is dismissed via the mouse
2024-12-12 17:24:25 -08:00
Marshall Bowers
937186da12
gpui: Don't export named Context from prelude (#21869)
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
2024-12-11 13:21:40 -05:00