zed icon indicating copy to clipboard operation
zed copied to clipboard

Collapse folder in file explorer discoverability

Open balaji-sivasakthi opened this issue 1 year ago • 21 comments

Check for existing issues

  • [X] Completed

Describe the feature

When I've big file tree, I need to close the all the opened child directories, this feature really helps when it comes to handy.

If applicable, add mockups / screenshots to help present your vision of the feature

Screenshot 2024-01-27 at 9 51 02 PM

balaji-sivasakthi avatar Jan 27 '24 16:01 balaji-sivasakthi

Is this what you're talking about?

{
  "context": "ProjectPanel && not_editing",
  "bindings": {
    "m": "project_panel::CollapseAllEntries"
  }
}

hhh

d1y avatar Jan 29 '24 07:01 d1y

Yes, @d1y

balaji-sivasakthi avatar Jan 29 '24 12:01 balaji-sivasakthi

This is great, would be nice to have an option to only close the children of the folder that is currently active. So if we have the below file structure where all folders are open and Folder 1 is selected in the side panel, running a collapse command on it would only collapse Folder 1 and Folder 1.2 but would leave Folder 2 and it's children open.

Project

  • Folder 1
    • Folder 1.1
      • file1.txt
  • Folder 2
    • Folder 2.1
      • file2.txt

project_panel::CollapseAllEntries fixes 99% of my use cases but it is nice to have the above functionality as well if possible one day 😊

itsmewes avatar Jan 30 '24 07:01 itsmewes

I'd love to see not only having a Key bind to close the Folders, but also to have a Icon to do it.

TheGlorySaint avatar Jan 30 '24 08:01 TheGlorySaint

Yeah, it's like there needs to be an option like project_panel::CollapseAllEntries but only for the selected folder and down, so like project_panel::CollapseAllEntriesBelowSelection or something.

orbiteleven avatar Jan 30 '24 13:01 orbiteleven

Yeah, it's like there needs to be an option like project_panel::CollapseAllEntries but only for the selected folder and down, so like project_panel::CollapseAllEntriesBelowSelection or something.

Agree with this. Having an option to be able to collapse a section using a Cmd+click like on VsCode could be really useful.

gh0stonio avatar Feb 14 '24 17:02 gh0stonio

I'd love to see not only having a Key bind to close the Folders, but also to have a Icon to do it.

+1

edtorba avatar Feb 16 '24 09:02 edtorba

Yeah definitely would love to have a button to collapse my entire directory tree. Especially helpful in big monorepos where you need to navigate between workspaces frequently.

segersniels avatar Mar 06 '24 23:03 segersniels

Is it possible to trigger this action from inside the editor pane? Right now I need to be focused in the LeftDock for this command to work

tomatau avatar Mar 12 '24 14:03 tomatau

That would be very nice, I use it every day.

AdamSchinzel avatar Mar 28 '24 08:03 AdamSchinzel

Im not sure if there's a better issue to comment on, but support for option + clicking folders in the explorer to toggle nested folders expansion state would be an amazing quality of life improvement.

https://github.com/zed-industries/zed/assets/104145051/936d0a2b-e1fc-4687-b56d-4389ce4e9400

cabaucom376 avatar Apr 16 '24 03:04 cabaucom376

Are we able to close this issue @balaji-sivasakthi? It seems like @d1y gave you a snippet that works for you? Or is there something else we need to do here? As for the follow-up requests - let's open new issues for those so that we can track interest on those items individually.

JosephTLyons avatar May 29 '24 20:05 JosephTLyons

Are we able to close this issue @balaji-sivasakthi? It seems like @d1y gave you a snippet that works for you? Or is there something else we need to do here? As for the follow-up requests - let's open new issues for those so that we can track interest on those items individually.

Adding the actual icon as shown in the screenshot would be nice. To be honest, many people won't find this issue and won't know about the key binding, imo.

edtorba avatar May 30 '24 06:05 edtorba

@JosephTLyons Yeah, key binding will work, but how will a new user realize that? Whether they search for this issue again or not, I think some people raise this issue often. So, my point of view is to bring that icon back, which will be more appropriate.

balaji-sivasakthi avatar May 30 '24 17:05 balaji-sivasakthi

@JosephTLyons Yeah, key binding will work, but how will a new user realize that? Whether they search for this issue again or not, I think some people raise this issue often. So, my point of view is to bring that icon back, which will be more appropriate.

Point noted - I rebranded this issue to be a discoverability issue and will leave it open.

JosephTLyons avatar May 31 '24 20:05 JosephTLyons

I have created this keymap but only works when focusing the project panel.

{
    "context": "ProjectPanel",
    "bindings": {
      "ctrl-alt-m": "project_panel::CollapseAllEntries"
    }
  }

Can this work anywhere?

Edit:

I have tried this but does not work either:

{
    "context": "Workspace",
    "bindings": {
      "ctrl-alt-m": "project_panel::CollapseAllEntries"
    }
  }

sant123 avatar Jul 12 '24 18:07 sant123

Some common patterns from other apps (I've synced this behavior across design apps and code editors):

  • Alt/Option click folder in file tree: close/open all descendants of that folder (no need for keyboard shortcut or icon for a given selection)
  • Alt/Option + L: close/collapse all open layers/folders in file tree (except the root level, if one exists). This one is handy to just generally "reset" the stage while working and browsing

The former is, in my opinion, a no-brainer addition that doesn't come in the way anywhere else, and common behavior across apps. The latter, I guess, is already possible in key bindings - but I wasn't able to get it working.

jerryjappinen avatar Jul 19 '24 08:07 jerryjappinen

Closing folders within the folder you close is the default behavior IIRC in JetBrains Rider. I really like that behavior and +1 the option to have it in Zed since I'm trying to make it my primary IDE. 😄

  • folder1 (opened)
    • some_file.rs
    • subfolder1 (opened)
      • another_file.rs

Close folder1

  • folder1 (closed)

Open folder1

  • folder1 (opened)
    • some_file.rs
    • subfolder1 (closed)

^^ closing folder1 would also close subfolder1, so when opening folder1 back up the subfolder1 remains closed.

A settings option would be great:

"project_panel": {
    // ... others
    "auto_close_subdirs": false // boolean - false by default for backward compat
}

onx2 avatar Jul 25 '24 19:07 onx2