Skip to content

Allow fuzzy search to match after cursor position - #96

Open
SephVelut wants to merge 3 commits into
zsh-users:masterfrom
SephVelut:patch-1
Open

Allow fuzzy search to match after cursor position#96
SephVelut wants to merge 3 commits into
zsh-users:masterfrom
SephVelut:patch-1

Conversation

@SephVelut

Copy link
Copy Markdown

No description provided.

#
local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
if [[ -z $HISTORY_SUBSTRING_SEARCH_FUZZY_AFTER_CURSOR ]]; then
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you factor out the duplication? 馃槺 It's safe to always execute this line. 馃 Next, you can conditionally prefix the * if this fuzzy-after-cursor option is not enabled.

Comment on lines +249 to +253
if [[ -z $HISTORY_SUBSTRING_SEARCH_FUZZY_AFTER_CURSOR ]]; then
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
else
local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if [[ -z $HISTORY_SUBSTRING_SEARCH_FUZZY_AFTER_CURSOR ]]; then
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
else
local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
fi
local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
if [[ -z $HISTORY_SUBSTRING_SEARCH_FUZZY_AFTER_CURSOR ]]; then
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
fi

I guess this would be the wanted behavior then?

@alichtman

Copy link
Copy Markdown

Any update on this?

@h0adp0re

Copy link
Copy Markdown

Would also be interested in seeing this merged.

@sunaku

sunaku commented Aug 3, 2021

Copy link
Copy Markdown
Member

Related PRs have been merged as of commit 4abed97. Please set the following configuration variable to enable this feature:

HISTORY_SUBSTRING_SEARCH_PREFIXED=1

Does this solve the problem this PR was meant to address?

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.

5 participants