Skip to content
Myr

Fix `^.*$` pattern matching in extended-search mode (#9)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 04ebadd · Browse files · 3 files+18 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+18 added−2 removed

  • tests:+14 added−0 removed
  • other:+4 added−2 removed

3 files+18 added−2 removed

modified:test/test_fzf.rb+14 added
195 unmodified lines
196 # ^197 assert_equal list.length, match.call('j', '').length198 assert_equal list.length - 1, match.call('^j', '').length199200 # ^ + $201 assert_equal 0, match.call('^juici$', '').length202 assert_equal 1, match.call('^juice$', '').length203 assert_equal 0, match.call('^.*$', '').length204205 # !206 assert_equal 0, match.call('!j', '').length207208 # ! + ^
127 unmodified lines
336 def test_split337 assert_equal ["a", "b", "c", "\xFF", "d", "e", "f"],338 FZF::UConv.split("abc\xFFdef")339 end340341 # ^$ -> matches empty item342 def test_format_empty_item343 fzf = FZF.new []344 item = ['', [[0, 0]]]345 line, offsets = fzf.convert_item item346 tokens = fzf.format line, 80, offsets347 assert_equal [], tokens348 end349end350
modified:fzf+3 added-1 removed
345 unmodified lines
346 tokens << [line[index...b], false]347 tokens << [line[b...e], true]348 index = e349 end350 tokens << [line[index..-1], false]350 tokens << [line[index..-1], false] if index < line.length351 tokens.reject { |pair| pair.first.empty? }352 end353354 def print_item row, tokens, chosen, selected
473 unmodified lines
828 [ @regexp[w] ||=829 case w830 when ''831 nil832 when /^\^(.*)\$$/833 Regexp.new('^' << sanitize(Regexp.escape $1) << '$', rxflag)834 when /^'/835 w.length > 1 ?836 Regexp.new(sanitize(Regexp.escape(w[1..-1])), rxflag) : nil837 when /^\^/
41 unmodified lines
modified:README.md+1 added-1 removed
187 unmodified lines
188}189190# fda - including hidden directories191fda() {192 DIR=$(find ${1:-*} -type d 2> /dev/null | fzf) && cd "$DIR"192 DIR=$(find ${1:-.} -type d 2> /dev/null | fzf) && cd "$DIR"193}194195# fh - repeat history196fh() {
183 unmodified lines