helix icon indicating copy to clipboard operation
helix copied to clipboard

S-return in file picker should open file in the background and keep the picker open with the same search query

Open emilyyyylime opened this issue 1 year ago • 10 comments

A lot of the time I want to open multiple files at once from the file picker and I think this small qol feature could make it easier to do so.

I would like to help write a PR to close this issue myself. Could anyone direct me as to where I should be looking to see how to make this work?

emilyyyylime avatar Sep 21 '22 14:09 emilyyyylime

Could anyone direct me as to where I should be looking to see how to make this work?

Take a look at helix-term/src/ui/picker.rs. Specifically line 535 is where it handles Enter events.

A-Walrus avatar Sep 22 '22 10:09 A-Walrus

I'd also love to see this feature added but just wanted to throw in some suggestions for how it could work:

  • Open picker, e.g. ~~Ctrl + Space~~ Space + / for a global search
  • For each file you want to open press ~~Ctrl + Enter~~ Tab. Rather than immediately opening the file it just marks the file(s) with an indicator such as * to show it is in the list of files to be opened
  • When finished selecting files press Enter. Each marked file is then opened as a new buffer and helix switches to editing the first buffer from the list.

The would enable scenarios such as searching across a codebase and editing multiple files matching a search criteria without having to repeat the search again. (I know there is a shortcut Space + ' to open the last picker but if you open another picker, such as diagnostics picker, while editing you will lose the results from the first picker and have to search again which can be frustrating).

@Itay123TheKing I hope my idea aligns with what you were thinking but please let me know what you think.

Edit: Updated what I think keybindings should be

gavynriebau avatar Oct 05 '22 07:10 gavynriebau

@gavynriebau I was thinking of some keybind that would simply load the file in a new buffer without closing the picker, that wy you could use that keybind on every file you want to open until the last one, which you could open with normal enter and it would close the picker and focus the new buffer. This approach also aligns really well with the existing code, adding *s to the files would require changing how the picker rendering works. Although the only reason I haven't yet submitted a PR with those changes, besides being too busy, is that it would seem <C+ret> doesn't get picked up by Helix currently, might have a special meaning for the terminal? Can you think of another keybind that could work there?

emilyyyylime avatar Oct 05 '22 18:10 emilyyyylime

@Itay123TheKing thanks, good call on Ctrl + Enter which I think often toggles terminal fullscreen. I edited my comment above with the suggestion that rather than using Ctrl + Enter just change the meaning of tab from "next entry" to "toggle marked for opening".

The user flow would then be arrow up/down and press Tab on files they want to open and when finished press Enter to open them all.

This would have the small advantage they could mark/unmark files for editing before opening them all in case they change their mind

gavynriebau avatar Oct 06 '22 00:10 gavynriebau

<S-ret> and <C-ret> are mistakenly interpreted by the terminal as just <ret>. We could use <A-ret> or now that https://github.com/helix-editor/helix/pull/3969 is in, we could repurpose <C-space>.

The checklist idea is interesting but it would take quite some work to implement. In scenarios where I want this feature, I have a file I'm interested in selected already and the file I'm really looking for still needs more typing to find. The "open in the background" idea works well for that but with checklists how do you see files that you've checked that no longer match the filter? Do they show up anyway?

the-mikedavis avatar Oct 21 '22 18:10 the-mikedavis

Ah, I see what you mean and in that case opening in the background definitely makes sense.

The ability to open in the background and the "checklist" type behaviour could be separate features but in this issue perhaps we should just focus on the original idea of opening files in the background.

I think the checklist style selection approach could work well with the open in background feature but could be added later

gavynriebau avatar Oct 22 '22 03:10 gavynriebau

<S-ret> and <C-ret> are mistakenly interpreted by the terminal as just <ret>. We could use <A-ret> or now that #3969 is in, we could repurpose <C-space>.

I don’t recommend using <C-space>, because some people use this to switch input methods, and I often use <C-space> on my iPad to switch input methods.

geometryolife avatar Oct 22 '22 03:10 geometryolife

Hey sorry for not working on this, I think I should be able to PR later today. But should we go A-ret or tab or?

emilyyyylime avatar Oct 23 '22 12:10 emilyyyylime

Also maybe right click should also do this?

emilyyyylime avatar Oct 23 '22 12:10 emilyyyylime

I hope I did this right. I decided not to implement right click because as I discovered not even left click is implemented

emilyyyylime avatar Oct 23 '22 17:10 emilyyyylime