Skip to content

Handle suggestions that are substrings of first suggestion #913

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ysthakur
Copy link
Member

@ysthakur ysthakur commented Jun 3, 2025

Currently, when finding a common prefix for partial completions, we assume that suggestions after the first one won't be substrings of the first suggestion. This PR handles that case.

We did have code handling the case when the first suggestion is a substring of a later suggestion, but it doesn't do case-insensitive comparison, so this PR takes care of that too.

@@ -162,38 +162,23 @@ pub fn parse_selection_char(buffer: &str, marker: char) -> ParseResult {

/// Finds index for the common string in a list of suggestions
pub fn find_common_string(values: &[Suggestion]) -> (Option<&Suggestion>, Option<usize>) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Side note: I would much rather this returned a single Option<(Suggestion, usize)> (or actually, an Option<&str>/Option<usize> would be even better, since callers can just get the first suggestion themselves). Didn't modify it in this PR because even though this helper's only used in one place in Reedline, consumers of Reedline might be using it for their menus.

@ysthakur ysthakur added A-Completions Area: Tab completion and inline hint completions P-low Low Priority: Implementation would be nice to have but does not severely impact quality of life labels Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Completions Area: Tab completion and inline hint completions P-low Low Priority: Implementation would be nice to have but does not severely impact quality of life
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant