Fish-like completions for nested directories#10543
Fish-like completions for nested directories#10543sophiajt merged 19 commits intonushell:mainfrom lavafroth:smart-path-completions
Conversation
Screencast.from.2023-09-29.13-07-41.webm |
|
This looks cool! Thanks! There is something similar to this with |
|
Update: I changed the functions a lot, making sure to conform to the engine_state for each completer (which I previously ignored). Also, I remove the prefix with the pathdiff crate to make relative paths like |
|
Have you tested it on Windows? I'm hoping it works there too. |
|
Actually, I haven't tested it on Windows yet. I'll need to setup a VM.
|
|
While you're testing, another thing to check for is if it works with filepaths that have spaces in them. |
|
Yep, it works fine with spaces. I checked that manually. Also the cargo tests cover that.
|
|
I just tested on Windows and it works as long as the slashes point left like regular windows slashes. Maybe it's just me, that's great, but I tend to cd /a/b/c/d even on Windows. Complete paths from root c:\ or \I'm not sure if it doesn't work with spaces in file names or if it just doesn't like what I'm doing. both go to the same folder Complete c:\temp as c:\there's another weird one completes to returns no records found In the root C:\no records found |
|
Can we utilize some property of the engine state to get the current drive?
|
|
I added support for drive letters like |
|
My preference would be for all these to "just work"
Basically, any slash direction with tab should work. I'm also fine with homogenizing the slashes so if you were to do something weird like I'm interested to see what others think. |
|
BTW, just let me say that is an epic PR. One of the biggest complaints we have is about completions not working the way people expect them to. This PR won't fix 100% of people's complaints, but man, it goes a long way to making our path completions better. Thanks so much for investing your time into nushell. ❤️ |
|
I think we should support the slash direction that's native for that platform for the first version of this change. If people want to it to be more flexible than that, we can improve it further later. Technically the other slash direction is valid as a filename, for example I can do |
|
Alright, I have implemented the slash homogenization. I also made sure to keep |
|
Bare string manipulations have been tedious, so I rewrote quite a bit of the code to use |
|
I'm happy to see the CI green. I fought with it yesterday because macos kept puking. I'm wondering if there's a way to add tests? If this works the way we want it to, we'd like to preserve that functionality and protect it from inadvertent changes breaking it. One way to do that is with some tests. |
|
Yes, I'll be adding tests for this shortly. In the meanitme, you might want to try it out, see if it feels natural.
|
|
I've tested it. I love it. ❤️ Everything that failed before on Windows is working great now! |
Typo checker thinks the partial "som" for the filename "somefile" is a typo. Checks out.
|
Whoops, typo checker thinks a file's prefix is a typo. I'll fix it. |
|
Let me know if there's anything else I have to do before this gets merged! |
fdncred
left a comment
There was a problem hiding this comment.
I like it and I'm ready to land it. Let's see if there are differing opinions.
|
+1 from me too. Let's do it. |
# Description This removes the old style "cd with abbreviations" that would attempt to guess what directory you wanted to `cd` to. This would sometimes have false positives, so we left it off by default in the config. In the current main, we have much-improved path completions (#10543) so you can now do `cd a/b<tab>` and get a much better experience (because you can see the directory you're about to cd to). This removes the need for the previous abbreviation system. # User-Facing Changes This does remove the old abbreviation system. It will likely mean that old config files that have settings for abbreviations will now get errors. update: here's an example of the error you'll see:  # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
|
I saw this new feature in the last 0.86 release, I've been looking forward for this in a long time! Thanks @lavafroth ❤️ |
it is now deprecated due to nushell/nushell#10543
<!-- if this PR closes one or more issues, you can automatically link the PR with them by using one of the [*linking keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword), e.g. - this PR should close nushell#5683 you can also mention related issues, PRs or discussions! --> # Description <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> This PR allows tab completion for nested directories while only specifying a part of the directory names. To illustrate this, if I type `tar/de/inc` and hit tab, it autocompletes to `./target/debug/incremental`. # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> Nested paths can be tab completed by typing lesser characters. # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> Tests cases are added. # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
# Description This removes the old style "cd with abbreviations" that would attempt to guess what directory you wanted to `cd` to. This would sometimes have false positives, so we left it off by default in the config. In the current main, we have much-improved path completions (nushell#10543) so you can now do `cd a/b<tab>` and get a much better experience (because you can see the directory you're about to cd to). This removes the need for the previous abbreviation system. # User-Facing Changes This does remove the old abbreviation system. It will likely mean that old config files that have settings for abbreviations will now get errors. update: here's an example of the error you'll see:  # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->




Description
This PR allows tab completion for nested directories while only specifying a part of the directory names. To illustrate this, if I type
tar/de/incand hit tab, it autocompletes to./target/debug/incremental.User-Facing Changes
Nested paths can be tab completed by typing lesser characters.
Tests + Formatting
Tests cases are added.
After Submitting