Fix missing NFD conversion in extended-search mode
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 90adda7 · Browse files · 3 files·+22 added−7 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+22 added−7 removed
- tests:+15 added−0 removed
- other:+7 added−7 removed
Provenance
- Commit
6a5e1de- Tree
13127de- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
90adda7
3 files changed+22 added−7 removed
modified:test/test_fzf.rb+15 added
294 unmodified lines295 nfd = FZF::UConv.nfd(nfc)296 assert_equal 6, nfd.length297 assert_equal NFD, nfd298 end299+300+ def test_nfd_fuzzy_matcher301+ matcher = FZF::FuzzyMatcher.new 0302+ match = matcher.match([NFD], '할', '', '')303+ assert_equal [[NFD, [[0, 6]]]], match304+ assert_equal ['한글', [[0, 2]]], FZF::UConv.nfc(*match.first)305+ end306+307+ def test_nfd_extended_fuzzy_matcher308+ matcher = FZF::ExtendedFuzzyMatcher.new 0309+ assert_equal [], matcher.match([NFD], "'할", '', '')310+ match = matcher.match([NFD], "'한글", '', '')311+ assert_equal [[NFD, [[0, 6]]]], match312+ assert_equal ['한글', [[0, 2]]], FZF::UConv.nfc(*match.first)313+ end314 end315 316 def test_split317 assert_equal ["a", "b", "c", "\xFF", "d", "e", "f"],4 unmodified linesmodified:fzf+6 added-6 removed
212 unmodified lines213 UConv.nfc(*item)214 end215 216 class Matcher217- def convert_query q217+ def query_chars q218 UConv.nfd(q).split(//)219 end220 end221 else1 unmodified line223 item224 end225 226 class Matcher227- def convert_query q227+ def query_chars q228 q.split(//)229 end230 end231 end514 unmodified lines746 747 def fuzzy_regex q748 @regexp[q] ||= begin749 q = q.downcase if @rxflag != 0750- Regexp.new(convert_query(q).inject('') { |sum, e|750+ Regexp.new(query_chars(q).inject('') { |sum, e|751 e = Regexp.escape e752 sum << "#{e}[^#{e}]*?"753 }, @rxflag)754 end48 unmodified lines803 when ''804 nil805 when /^'/806 w.length > 1 ?807- Regexp.new(Regexp.escape(w[1..-1]), rxflag) : nil807+ Regexp.new(UConv.nfd(Regexp.escape(w[1..-1])), rxflag) : nil808 when /^\^/809 w.length > 1 ?810- Regexp.new('^' << Regexp.escape(w[1..-1]), rxflag) : nil810+ Regexp.new('^' << UConv.nfd(Regexp.escape(w[1..-1])), rxflag) : nil811 when /\$$/812 w.length > 1 ?813- Regexp.new(Regexp.escape(w[0..-2]) << '$', rxflag) : nil813+ Regexp.new(UConv.nfd(Regexp.escape(w[0..-2])) << '$', rxflag) : nil814 else815 fuzzy_regex w816 end, invert ]817 }.select { |pair| pair.first }32 unmodified linesmodified:fzf.gemspec+1 added-1 removed
1 # coding: utf-82 Gem::Specification.new do |spec|3 spec.name = 'fzf'4- spec.version = '0.4.0'4+ spec.version = '0.4.1'5 spec.authors = ['Junegunn Choi']6 spec.email = ['junegunn.c@gmail.com']7 spec.description = %q{Fuzzy finder for your shell}8 spec.summary = %q{Fuzzy finder for your shell}7 unmodified lines