-
-
Notifications
You must be signed in to change notification settings - Fork 299
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
Keep and document implicit cd? The /
(division command) invoked with no args does cd /
#1099
Comments
This results in pkg/eval/builtin_fn_num.go having only one untested statement and that is being discussed in elves#1099. Related elves#1062
I never use implicit |
Yes ideally this should be a feature of the editor not the language itself. However, implicit cd is a feature that is hard to separate from the language. What do y'all think about letting the location mode accept literal paths? The logic can work like:
A small downside is that tab completion is lost - but in that case the user could revert to using |
That's preferable to the current behavior but I'm not sure it's worth saving one to three keystrokes. Especially since it doesn't support tab completion. Consider the scenario where CWD is $HOME and I have a tmp subdir. Today I can't type |
/
(division command) invoked with no args does cd /
/
(division command) invoked with no args does cd /
There was a recent discussion, in the context of issue #1170, that Navigation mode does two things:
Location mode only changes the CWD. Ideally only Location mode would support changing the CWD while melding the current behavior (selecting an item from the CWD history) and Navigation mode. Then Navigation mode would only be used for selecting filenames, not changing the CWD. I have no idea what such a UI would look like. But I'm extremely unhappy that using Navigation mode to insert filenames on the command line also, as a side-effect, changes the CWD. |
That is a good point.
That's a fair point; it only saves 1 keystroke in this example, but for
I am not convinced that the navigation mode has a broken operation model - it might help a bit if you think of the primary purpose of the navigation mode as, well, navigating in the filesystem, and the functionality to insert filename as a secondary functionality. Feel free to open another issue if you'd like to discuss this further. |
I would agree if we were talking about how people interacted with computers more than two decades ago. Which includes me since I started programming in high-school in 1977. Which is why so many UNIX commands are cryptic. Nonetheless, directory changes, at least in a particular session for me, is rare enough that eliding the |
I still feel, quite strongly, that implicit cd has more problems than the value of eliding three keystrokes in situations most users will never care about. The fact this feature is only documented in the If nothing else consider that the implicit "cd" string is recorded in the interactive command history without a "cd " prefix. So if I start a new Elvish shell and select that "command" it might change to that directory or might run a command of the same name. Ugh! |
It looks like I might have misunderstood an earlier comment by @xiaq regarding location mode. I agree that augmenting location mode to special-case paths such as Also, I should have noted earlier that the implicit cd behavior isn't implemented solely by the elvish/pkg/eval/external_cmd.go Lines 55 to 68 in 4717deb
Note that Lines 14 to 17 in 4717deb
|
In case the implications of that statement weren't obvious create and run the following Elvish program:
I can't see a good reason to support that even if you ignore the fact that the UNIX meaning for |
Having read this issue again, more than a year after my last comment, I am still convinced that the implicit |
Searching for commands that mention
Most users will ask why those seemingly do nothing rather than throw an exception since they are not valid Elvish statements. The implicit |
Not to mention that invalid paths do not perform an implicit
Compare that with this example:
I don't see a good reason for the two error messages to be different. Yes, the former is an explicit path that bypasses searching the Also, that the first example says "Exception: exec:" is questionable since it was also attempting an implicit |
Removing implicit cd from the language sounds fine as long as location mode gains the functionality of doing a literal chdir. |
Enhancing location mode to support a filter that puts the filter string at the top of the directory list if it corresponds to a literal directory is trivial. The hardest part of this change is an appropriate unit test. The second hardest aspect is the documentation. So I'll tackle this. I should have a pull-request in a day or two. |
LOL! Implementing this, including a relevant unit test on Unix platforms, is straightforward. Testing it on Windows is more difficult. |
Replace the CLI implicit `cd` behavior with location mode support for literal directory paths. Fixes elves#1099
Replace the CLI implicit `cd` behavior with location mode support for literal directory paths. Fixes elves#1099
Replace the CLI implicit `cd` behavior with location mode support for literal directory paths. Fixes elves#1099
While chipping away at issue #1062 to improve unit test coverage I noticed this block of code:
elvish/pkg/eval/builtin_fn_num.go
Lines 281 to 289 in 3300c81
I noticed it because no unit test exercises the
return fm.Chdir("/")
statement and I was surprised that module did not have 100% coverage.I could add a test for that case but I think the feature should be removed. Note that the only place I can find that documents the "implicit cd" feature is for the
/
command.Note that the current behavior can result in silent bugs:
That chdir should not have occurred.
The text was updated successfully, but these errors were encountered: