Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command for picking files from CWD #1600

Merged
merged 1 commit into from
Apr 10, 2022

Conversation

gavynriebau
Copy link
Contributor

The file_picker_at_cwd command opens the file picker at the current
working directory (CWD). This can be useful when paired with the
built-in :cd command which changes the CWD.

@gavynriebau
Copy link
Contributor Author

gavynriebau commented Jan 29, 2022

Demo

file_picker_at_cwd.mp4

In the above demo I remapped space f to a "Files" submenu which contains entries for both the original "Open file picker" and the new "Open file picker at current working directory" commands.

I haven't included that keymapping change in this PR due to ongoing discussion in #1352 about the best way to keymap new file picker type commands.

@EpocSquadron
Copy link
Contributor

There is an interesting interaction here with some of the logic inside the file_picker method, where it decides whether to limit the number of items in the picker to 8196 if the root directory is not a directory containing a .git. This could theoretically impact the sorting in a subdirectory if the subdirectory is quite large, I think.

@sudormrfbin
Copy link
Member

There's also #1066 that gives higher precedence to files in the CWD in the default file picker itself.

@gavynriebau
Copy link
Contributor Author

gavynriebau commented Feb 23, 2022

There's also #1066 that gives higher precedence to files in the CWD in the default file picker itself.

Thanks, the issue is that if there are a large number of directories/files in the root of a project, they will clutter up the list of results.
Being able to cd to a subdirectory and the pop the file picker in a mode that only shows the files in the CWD would be really useful to me because provides a smaller and clearer list of results to pick from.

@@ -3258,6 +3259,12 @@ fn file_picker(cx: &mut Context) {
cx.push_layer(Box::new(picker));
}

fn file_picker_at_cwd(cx: &mut Context) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about mapping this to space F by default? Would complement space f

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also rename it file_picker_in_current_directory

Copy link
Contributor Author

@gavynriebau gavynriebau Apr 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've renamed the function, added a keymap bound to space F, rebased onto the latest master and pushed the updated changes into this PR

@slinlee
Copy link
Contributor

slinlee commented Mar 25, 2022

Resolves #1860

The `file_picker_at_current_directory` command opens the file picker at
the current working directory (CWD). This can be useful when paired with
the built-in `:cd` command which changes the CWD.

It has been mapped to `space F` by default.
@gavynriebau gavynriebau force-pushed the add-file-picker-for-cwd branch from b61e216 to e55f3af Compare April 8, 2022 02:14
Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@archseer archseer merged commit 562874a into helix-editor:master Apr 10, 2022
@David-Else
Copy link
Contributor

David-Else commented Apr 10, 2022

If I open Helix in a directory and pwd it says that is the current working directory. Is this not the main working directory as opposed to/as well as the current working directory? If we now have a file picker for the current working directory then there needs to be a new distinction between the two.

If I cd into a subdirectory x then it says current working directory is now x.

  • space f opens the previous directory (main working directory?),
  • space F opens x (current working directory).

The menu says "f Open file picker", but open it where? Is this known as the main working directory or some other name? If so, it should say in the menu as things are now confusing.

There is now two distinct types of directory for the file picker, and the main working directory needs to be referenced in the docs and other commands now.

PS I am not saying it needs to be called main working directory, but what should it be called? git root? Is it decided in a different way by each LSP server, or is it just the first directory you open?

@the-mikedavis
Copy link
Member

I think "workspace directory" would be an improvement, but that might start to cross terminology with LSP.

@David-Else
Copy link
Contributor

We need to clarify what is:

  • 'current working directory'
  • 'workspace directory' (or another name)
  • 'LSP workspace directory' (or another name)

I am confused myself.

@EpocSquadron
Copy link
Contributor

I usually refer to it as "project root", which jives with the roots language config key.

@David-Else
Copy link
Contributor

pwd shows current working directory, how do we display `project root' directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants