mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-25 12:10:04 +00:00
Fix missing NFD conversion in extended-search mode
This commit is contained in:
parent
90adda73b0
commit
6a5e1de6f3
12
fzf
12
fzf
@ -214,7 +214,7 @@ class FZF
|
||||
end
|
||||
|
||||
class Matcher
|
||||
def convert_query q
|
||||
def query_chars q
|
||||
UConv.nfd(q).split(//)
|
||||
end
|
||||
end
|
||||
@ -224,7 +224,7 @@ class FZF
|
||||
end
|
||||
|
||||
class Matcher
|
||||
def convert_query q
|
||||
def query_chars q
|
||||
q.split(//)
|
||||
end
|
||||
end
|
||||
@ -747,7 +747,7 @@ class FZF
|
||||
def fuzzy_regex q
|
||||
@regexp[q] ||= begin
|
||||
q = q.downcase if @rxflag != 0
|
||||
Regexp.new(convert_query(q).inject('') { |sum, e|
|
||||
Regexp.new(query_chars(q).inject('') { |sum, e|
|
||||
e = Regexp.escape e
|
||||
sum << "#{e}[^#{e}]*?"
|
||||
}, @rxflag)
|
||||
@ -804,13 +804,13 @@ class FZF
|
||||
nil
|
||||
when /^'/
|
||||
w.length > 1 ?
|
||||
Regexp.new(Regexp.escape(w[1..-1]), rxflag) : nil
|
||||
Regexp.new(UConv.nfd(Regexp.escape(w[1..-1])), rxflag) : nil
|
||||
when /^\^/
|
||||
w.length > 1 ?
|
||||
Regexp.new('^' << Regexp.escape(w[1..-1]), rxflag) : nil
|
||||
Regexp.new('^' << UConv.nfd(Regexp.escape(w[1..-1])), rxflag) : nil
|
||||
when /\$$/
|
||||
w.length > 1 ?
|
||||
Regexp.new(Regexp.escape(w[0..-2]) << '$', rxflag) : nil
|
||||
Regexp.new(UConv.nfd(Regexp.escape(w[0..-2])) << '$', rxflag) : nil
|
||||
else
|
||||
fuzzy_regex w
|
||||
end, invert ]
|
||||
|
@ -1,7 +1,7 @@
|
||||
# coding: utf-8
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = 'fzf'
|
||||
spec.version = '0.4.0'
|
||||
spec.version = '0.4.1'
|
||||
spec.authors = ['Junegunn Choi']
|
||||
spec.email = ['junegunn.c@gmail.com']
|
||||
spec.description = %q{Fuzzy finder for your shell}
|
||||
|
@ -296,6 +296,21 @@ class TestFZF < MiniTest::Unit::TestCase
|
||||
assert_equal 6, nfd.length
|
||||
assert_equal NFD, nfd
|
||||
end
|
||||
|
||||
def test_nfd_fuzzy_matcher
|
||||
matcher = FZF::FuzzyMatcher.new 0
|
||||
match = matcher.match([NFD], '할', '', '')
|
||||
assert_equal [[NFD, [[0, 6]]]], match
|
||||
assert_equal ['한글', [[0, 2]]], FZF::UConv.nfc(*match.first)
|
||||
end
|
||||
|
||||
def test_nfd_extended_fuzzy_matcher
|
||||
matcher = FZF::ExtendedFuzzyMatcher.new 0
|
||||
assert_equal [], matcher.match([NFD], "'할", '', '')
|
||||
match = matcher.match([NFD], "'한글", '', '')
|
||||
assert_equal [[NFD, [[0, 6]]]], match
|
||||
assert_equal ['한글', [[0, 2]]], FZF::UConv.nfc(*match.first)
|
||||
end
|
||||
end
|
||||
|
||||
def test_split
|
||||
|
Loading…
Reference in New Issue
Block a user