diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2017-08-09 23:25:32 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-08-09 23:28:47 +0900 |
commit | e85a8a68d0248a6edfb6ef63c5edb4bcbe18f954 (patch) | |
tree | 0831c315a1022f08eaa2331f58015fb5c61007c5 /test | |
parent | dc55e68524a84544417c1ce290df447c4f0b1d60 (diff) |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/test_go.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_go.rb b/test/test_go.rb index f001ec69..3460f56b 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -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 |