ZIm/crates
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
..
activity_indicator Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
anthropic Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
assets Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
assistant Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
assistant2 assistant2: Add tiny visual adjustments (#23748) 2025-01-27 20:26:34 -03:00
assistant_context_editor Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
assistant_settings Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
assistant_slash_command Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
assistant_slash_commands Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
assistant_tool Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
assistant_tools Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
audio Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
auto_update Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
auto_update_ui Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
breadcrumbs Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
call Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
channel Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
cli Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
client Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
clock chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
collab project_panel: Add Alt/Opt+Click to expand/collapse a directory and all its contents (#22896) 2025-01-28 10:37:56 +02:00
collab_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
collections chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
command_palette Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
command_palette_hooks Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
context_server Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
context_server_settings Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
copilot Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
db Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
deepseek Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
diagnostics Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
docs_preprocessor Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
editor Fix run indicators with expanded diff hunks (#23758) 2025-01-27 23:05:46 -07:00
evals Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
extension Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
extension_api chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
extension_cli chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
extension_host Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
extensions_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
feature_flags Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
feedback Update actions to open GitHub issue templates (#23747) 2025-01-27 18:17:43 -05:00
file_finder Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
file_icons Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
fireworks chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
fs Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
fsevent chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
fuzzy chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
git Fix unnecessarily large edits emitted from multi buffer on diff recalculation (#23753) 2025-01-27 18:11:15 -08:00
git_hosting_providers Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
git_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
go_to_line Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
google_ai chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
gpui windows: Refactor mouse events related code (#23729) 2025-01-28 15:48:43 +08:00
gpui_macros Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
html_to_markdown Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
http_client chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
image_viewer Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
indexed_docs Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
inline_completion Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
inline_completion_button Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
install_cli Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
journal Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
language Silence Rust-Analyzer false-positive (#23724) 2025-01-27 16:38:03 +00:00
language_extension Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
language_model Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
language_model_selector assistant: Preserve selection focus in the model selector (#23713) 2025-01-27 12:29:08 -03:00
language_models Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
language_selector Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
language_tools Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
languages Add auto-completion support for snippet files (#23698) 2025-01-27 12:32:22 +01:00
livekit_client Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
livekit_client_macos Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
livekit_server chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
lmstudio Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
lsp Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
markdown Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
markdown_preview Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
media chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
menu chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
multi_buffer Fix run indicators with expanded diff hunks (#23758) 2025-01-27 23:05:46 -07:00
node_runtime chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
notifications Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
ollama Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
open_ai openai: Add back O1-Preview (#23715) 2025-01-27 14:44:12 +00:00
outline Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
outline_panel Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
paths Add auto-completion support for snippet files (#23698) 2025-01-27 12:32:22 +01:00
picker Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
prettier Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
project project_panel: Add Alt/Opt+Click to expand/collapse a directory and all its contents (#22896) 2025-01-28 10:37:56 +02:00
project_panel project_panel: Add Alt/Opt+Click to expand/collapse a directory and all its contents (#22896) 2025-01-28 10:37:56 +02:00
project_symbols Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
prompt_library Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
proto project_panel: Add Alt/Opt+Click to expand/collapse a directory and all its contents (#22896) 2025-01-28 10:37:56 +02:00
recent_projects Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
refineable project: Revert project tree impl (again) (#23572) 2025-01-23 16:10:38 -05:00
release_channel Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
remote Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
remote_server Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
repl Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
reqwest_client Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
rich_text Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
rope Rework go to line infrastructure (#23654) 2025-01-25 19:24:19 +00:00
rpc Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
search Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
semantic_index Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
semantic_version chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
session Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
settings Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
settings_ui Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
snippet Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
snippet_provider Add auto-completion support for snippet files (#23698) 2025-01-27 12:32:22 +01:00
snippets_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
sqlez Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
sqlez_macros chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
story Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
storybook Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
streaming_diff chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
sum_tree Rework diff rendering to allow putting the cursor into deleted text, soft-wrapping and scrolling deleted text correctly (#22994) 2025-01-24 14:18:22 -07:00
supermaven Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
supermaven_api Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
tab_switcher Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
task Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
tasks_ui Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
telemetry chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
telemetry_events chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
terminal Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
terminal_view Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
text Fix unnecessarily large edits emitted from multi buffer on diff recalculation (#23753) 2025-01-27 18:11:15 -08:00
theme Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
theme_extension Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
theme_importer Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
theme_selector Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
time_format chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
title_bar Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
toolchain_selector Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
ui Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
ui_input Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
ui_macros Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
util Canonicalize paths when running tests (#23655) 2025-01-26 14:56:07 +08:00
vcs_menu Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
vim vim: Fix NextSubwordEnd crash (#23604) 2025-01-27 23:13:13 -07:00
vim_mode_setting Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
welcome Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
workspace workspace: Prefer active window over other local non-collab windows for opening file (#23726) 2025-01-27 23:11:35 -07:00
worktree project_panel: Add Alt/Opt+Click to expand/collapse a directory and all its contents (#22896) 2025-01-28 10:37:56 +02:00
zed Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
zed_actions Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
zed_predict_tos Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
zeta Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00