mirror of
https://github.com/junegunn/fzf.git
synced 2025-07-31 04:02:01 -07:00
Fix escaping of meta characters after ' or ! prefix
https://github.com/junegunn/fzf/issues/444#issuecomment-321432803
This commit is contained in:
@@ -182,7 +182,9 @@ func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(text, "'") {
|
if _escapedPrefixRegex.MatchString(text) {
|
||||||
|
text = text[1:]
|
||||||
|
} else if strings.HasPrefix(text, "'") {
|
||||||
// Flip exactness
|
// Flip exactness
|
||||||
if fuzzy && !inv {
|
if fuzzy && !inv {
|
||||||
typ = termExact
|
typ = termExact
|
||||||
@@ -200,10 +202,6 @@ func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet
|
|||||||
text = text[1:]
|
text = text[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
if _escapedPrefixRegex.MatchString(text) {
|
|
||||||
text = text[1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(text) > 0 {
|
if len(text) > 0 {
|
||||||
if switchSet {
|
if switchSet {
|
||||||
sets = append(sets, set)
|
sets = append(sets, set)
|
||||||
|
@@ -1400,6 +1400,16 @@ class TestGoFZF < TestBase
|
|||||||
assert_equal [], `#{FZF} -f"'br" < #{tempname}`.lines.map(&:chomp)
|
assert_equal [], `#{FZF} -f"'br" < #{tempname}`.lines.map(&:chomp)
|
||||||
assert_equal ["foo'bar"], `#{FZF} -f"\\'br" < #{tempname}`.lines.map(&:chomp)
|
assert_equal ["foo'bar"], `#{FZF} -f"\\'br" < #{tempname}`.lines.map(&:chomp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_escaped_meta_characters_only_on_relevant_positions
|
||||||
|
input = <<~EOF
|
||||||
|
\\^
|
||||||
|
^
|
||||||
|
EOF
|
||||||
|
writelines tempname, input.lines.map(&:chomp)
|
||||||
|
assert_equal %w[^ \\^], `#{FZF} -f"\\^" < #{tempname}`.lines.map(&:chomp)
|
||||||
|
assert_equal %w[\\^], `#{FZF} -f"'\\^" < #{tempname}`.lines.map(&:chomp)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module TestShell
|
module TestShell
|
||||||
|
Reference in New Issue
Block a user