From e85a8a68d0248a6edfb6ef63c5edb4bcbe18f954 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 9 Aug 2017 23:25:32 +0900 Subject: Allow escaping meta characters with backslashes One can escape meta characters in extended-search mode with backslashes. Prefixes: \' \! \^ Suffix: \$ Term separator: \ 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 --- test/test_go.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') 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 -- cgit v1.2.3