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

Deduplicate argument history suggestions #4795

Closed
mqudsi opened this Issue Mar 9, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@mqudsi
Copy link
Contributor

mqudsi commented Mar 9, 2018

Currently, argument history iteration is a huge chore because it is extremely naïve as currently implemented and suggests literally every argument in the history that matches the current prefix, regardless if it's already been suggested or not.

Consider the following history items:

cp file1 file2
rm file1
touch file4
touch file1
mv file1 file3
cp file<UP>

The suggestions on repeated <UP> will be file3, file1, file4, file1, and finally file2 (which is what I want). While these arguments are taken from deduplicated history entries, the completion arguments themselves are duplicates of previous suggestions. If I bypassed file1 the first time, there's no reason to suggest it the second time.

@mqudsi mqudsi changed the title Deduplicate argument history iteration Deduplicate argument history suggestions Mar 9, 2018

@faho faho added the enhancement label Mar 13, 2018

@faho faho added this to the fish-future milestone Mar 13, 2018

@zx8

This comment has been minimized.

Copy link

zx8 commented Aug 10, 2018

@ridiculousfish I know it's a long shot, but since you're currently poking around the completion/suggestion code (looking at recent commits on master), any chance you could take a stab at this? 🙏

It's super annoying to have the same argument suggested over and over after I've skipped it the first time!

@ridiculousfish

This comment has been minimized.

Copy link
Member

ridiculousfish commented Aug 11, 2018

I think this is about token history search (alt-up). Yes this should be easy to fix.

@zx8

This comment has been minimized.

Copy link

zx8 commented Aug 15, 2018

Edit: Raised as a separate issue here: #5150


@ridiculousfish e51e854 is awesome, but has ever so slightly changed/broken the traversal order of history arguments (i.e. history-token-search-backward):

Prior/expected behaviour:

$ echo foo bar baz
foo bar baz
# alt-.
$ baz
# alt-.
$ bar
# alt-.
$ foo

Current/unexpected behaviour:

$ echo foo bar baz
foo bar baz
# alt-.
$ echo
# alt-.
$ foo
# alt-.
$ bar

Would it be possible to reinstate the old traversal order? More often than not, whenever I press alt-. it's to recall the last argument of the previous command. This would also be consistent with bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment