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

Allow fuzzy search to match after cursor position #96

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

Conversation

SephVelut
Copy link

No description provided.

@@ -246,7 +246,11 @@ _history-substring-search-begin() {
# Escape and join query parts with wildcard character '*' as seperator
# `(j:CHAR:)` join array to string with CHAR as seperator
#
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
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

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

Any update on this?

@h0adp0re
Copy link

Would also be interested in seeing this merged.

@sunaku
Copy link
Member

sunaku commented Aug 3, 2021

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.

None yet

5 participants