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 Option for Prefix-Based Reverse Search #424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oberien
Copy link

@oberien oberien commented Aug 2, 2020

Allow history search via Arrow-Up/Down or C-p/n to go either line-by-line or based on the prefix before the cursor position

Fix #423

} else {
self.out.beep()
self.restore();
Copy link
Author

Choose a reason for hiding this comment

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

I don't know if this restore breaks the following code:

rustyline/src/lib.rs

Lines 558 to 559 in 88e669c

Cmd::HistorySearchBackward => s.edit_history_search(Direction::Reverse, false)?,
Cmd::HistorySearchForward => s.edit_history_search(Direction::Forward, false)?,

@oberien
Copy link
Author

oberien commented Oct 31, 2020

I rebased this PR to the newest master. Is there anything that's missing for a review?

@oberien oberien changed the title Add History Search Behaviour Add Option for Prefix-Based Reverse Search Apr 10, 2021
@oberien oberien force-pushed the history-search-behaviour branch 3 times, most recently from 7a3494c to 6743738 Compare April 17, 2021 15:02
@oberien
Copy link
Author

oberien commented Apr 17, 2021

I squashed my commits to make rebasing easier and rebased onto the current master.

The issue behind this PR in nushell comes up every now and again to allow nushell to have zsh-similar search behaviour taking into account the typed prefix. Is there anything I can do to help get this PR merged?

@oberien
Copy link
Author

oberien commented May 20, 2021

@gwenn Is this PR something that could be of interest to rustyline?

@fdncred
Copy link

fdncred commented Jun 2, 2021

@gwenn We would really like to have this on nushell. Can you please look at this PR?

Allow history search via Arrow-Up/Down or C-p/n to go either line-by-line or based on the prefix before the cursor position

Fix kkawakam#423
Direction::Forward => history.len(),
Direction::Reverse => 0,
};
self.restore();
Copy link
Collaborator

@gwenn gwenn Jun 22, 2021

Choose a reason for hiding this comment

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

bash history-search-backward does not seem to loop or skip same history entries.
But you are right: cursor position is preserved.
I guess we should be able to use only a ConditionalEventHandler: if no prefix => PreviousHistory/ NextHistory else => HistorySearchBackward / HistorySearchForward.

@gwenn
Copy link
Collaborator

gwenn commented Jul 14, 2021

eb68960 preserves cursor position.

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.

Use Arrow-Up to search history with prefix
3 participants