mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-25 14:17:40 +00:00
Fix ^.*$
pattern matching in extended-search mode (#9)
This commit is contained in:
parent
04ebaddf5e
commit
cb3645ea95
@ -189,7 +189,7 @@ fd() {
|
||||
|
||||
# fda - including hidden directories
|
||||
fda() {
|
||||
DIR=$(find ${1:-*} -type d 2> /dev/null | fzf) && cd "$DIR"
|
||||
DIR=$(find ${1:-.} -type d 2> /dev/null | fzf) && cd "$DIR"
|
||||
}
|
||||
|
||||
# fh - repeat history
|
||||
|
4
fzf
4
fzf
@ -347,7 +347,7 @@ class FZF
|
||||
tokens << [line[b...e], true]
|
||||
index = e
|
||||
end
|
||||
tokens << [line[index..-1], false]
|
||||
tokens << [line[index..-1], false] if index < line.length
|
||||
tokens.reject { |pair| pair.first.empty? }
|
||||
end
|
||||
|
||||
@ -829,6 +829,8 @@ class FZF
|
||||
case w
|
||||
when ''
|
||||
nil
|
||||
when /^\^(.*)\$$/
|
||||
Regexp.new('^' << sanitize(Regexp.escape $1) << '$', rxflag)
|
||||
when /^'/
|
||||
w.length > 1 ?
|
||||
Regexp.new(sanitize(Regexp.escape(w[1..-1])), rxflag) : nil
|
||||
|
@ -197,6 +197,11 @@ class TestFZF < MiniTest::Unit::TestCase
|
||||
assert_equal list.length, match.call('j', '').length
|
||||
assert_equal list.length - 1, match.call('^j', '').length
|
||||
|
||||
# ^ + $
|
||||
assert_equal 0, match.call('^juici$', '').length
|
||||
assert_equal 1, match.call('^juice$', '').length
|
||||
assert_equal 0, match.call('^.*$', '').length
|
||||
|
||||
# !
|
||||
assert_equal 0, match.call('!j', '').length
|
||||
|
||||
@ -332,5 +337,14 @@ class TestFZF < MiniTest::Unit::TestCase
|
||||
assert_equal ["a", "b", "c", "\xFF", "d", "e", "f"],
|
||||
FZF::UConv.split("abc\xFFdef")
|
||||
end
|
||||
|
||||
# ^$ -> matches empty item
|
||||
def test_format_empty_item
|
||||
fzf = FZF.new []
|
||||
item = ['', [[0, 0]]]
|
||||
line, offsets = fzf.convert_item item
|
||||
tokens = fzf.format line, 80, offsets
|
||||
assert_equal [], tokens
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user