mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 15:23:48 -05:00
Allow escaping meta characters with backslashes
One can escape meta characters in extended-search mode with backslashes.
Prefixes:
\'
\!
\^
Suffix:
\$
Term separator:
\<SPACE>
To keep things simple, we are not going to support escaping of escaped
sequences (e.g. \\') for matching them literally.
Since this is a breaking change, we will bump the minor version.
Close #444
This commit is contained in:
@@ -1378,6 +1378,28 @@ class TestGoFZF < TestBase
|
||||
tmux.send_keys 'a'
|
||||
tmux.until { |lines| lines.none? { |line| line.include? '1 2 3 4 5' } }
|
||||
end
|
||||
|
||||
def test_escaped_meta_characters
|
||||
input = <<~EOF
|
||||
foo^bar
|
||||
foo$bar
|
||||
foo!bar
|
||||
foo'bar
|
||||
foo bar
|
||||
bar foo
|
||||
EOF
|
||||
writelines tempname, input.lines.map(&:chomp)
|
||||
|
||||
assert_equal input.lines.count, `#{FZF} -f'foo bar' < #{tempname}`.lines.count
|
||||
assert_equal ['foo bar'], `#{FZF} -f'foo\\ bar' < #{tempname}`.lines.map(&:chomp)
|
||||
assert_equal ['bar foo'], `#{FZF} -f'foo$' < #{tempname}`.lines.map(&:chomp)
|
||||
assert_equal ['foo$bar'], `#{FZF} -f'foo\\$' < #{tempname}`.lines.map(&:chomp)
|
||||
assert_equal [], `#{FZF} -f'!bar' < #{tempname}`.lines.map(&:chomp)
|
||||
assert_equal ['foo!bar'], `#{FZF} -f'\\!bar' < #{tempname}`.lines.map(&:chomp)
|
||||
assert_equal ['foo bar'], `#{FZF} -f'^foo\\ bar$' < #{tempname}`.lines.map(&:chomp)
|
||||
assert_equal [], `#{FZF} -f"'br" < #{tempname}`.lines.map(&:chomp)
|
||||
assert_equal ["foo'bar"], `#{FZF} -f"\\'br" < #{tempname}`.lines.map(&:chomp)
|
||||
end
|
||||
end
|
||||
|
||||
module TestShell
|
||||
|
||||
Reference in New Issue
Block a user