Fix logic used to build fuzzy search regex

The intent was to insert '*' between all characters in the query, except
for those which were escaped with '\'. What the old implementation did,
however, was strip out all backslashes and place '*' between all
remaining characters, as when a backslash was detected the loop would
skip to the next character without appending the backslash to the regex.

The new logic is something like "add the character, then add '*' if the
character was not a backslash", which should be correct
This commit is contained in:
Alex Wang 2016-09-03 14:28:05 -04:00
parent 9d291f18f7
commit 9551fe6cc7

View file

@ -220,8 +220,8 @@ _history-substring-search-begin() {
fuzzy_regex="*"
for char ({1..$#escaped_query}); do
[[ escaped_query[$char] == '\' ]] && continue
fuzzy_regex+="${escaped_query[$char]}*"
fuzzy_regex+="${escaped_query[$char]}"
[[ escaped_query[$char] != '\' ]] && fuzzy_regex+="*"
done
#