Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fzf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
fzf
Commits
f6df1eaa
Commit
f6df1eaa
authored
11 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Support NFD Hangul path on OS X
parent
2864e235
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fzf
+85
-5
85 additions, 5 deletions
fzf
with
85 additions
and
5 deletions
fzf
+
85
−
5
View file @
f6df1eaa
...
...
@@ -10,7 +10,7 @@
# URL: https://github.com/junegunn/fzf
# Author: Junegunn Choi
# License: MIT
# Last update: October 2
4
, 2013
# Last update: October 2
8
, 2013
#
# Copyright (c) 2013 Junegunn Choi
#
...
...
@@ -74,6 +74,86 @@ require 'curses'
@vcursor
=
0
@events
=
{}
case
RUBY_PLATFORM
when
/darwin/
module
UConv
CHOSUNG
=
0x1100
JUNGSUNG
=
0x1161
JONGSUNG
=
0x11A7
CHOSUNGS
=
19
JUNGSUNGS
=
21
JONGSUNGS
=
28
JJCOUNT
=
JUNGSUNGS
*
JONGSUNGS
NFC_BEGIN
=
0xAC00
NFC_END
=
NFC_BEGIN
+
CHOSUNGS
*
JUNGSUNGS
*
JONGSUNGS
def
self
.
nfd
str
ret
=
''
str
.
split
(
//
).
each
do
|
c
|
cp
=
c
.
ord
if
cp
>=
NFC_BEGIN
&&
cp
<
NFC_END
idx
=
cp
-
NFC_BEGIN
cho
=
CHOSUNG
+
idx
/
JJCOUNT
jung
=
JUNGSUNG
+
(
idx
%
JJCOUNT
)
/
JONGSUNGS
jong
=
JONGSUNG
+
idx
%
JONGSUNGS
ret
<<
cho
<<
jung
ret
<<
jong
if
jong
!=
JONGSUNG
else
ret
<<
c
end
end
ret
end
def
self
.
nfc
str
,
offset
ret
=
''
omap
=
[]
pend
=
[]
str
.
split
(
//
).
each_with_index
do
|
c
,
idx
|
cp
=
c
.
ord
omap
<<
ret
.
length
unless
pend
.
empty?
if
cp
>=
JUNGSUNG
&&
cp
<
JUNGSUNG
+
JUNGSUNGS
pend
<<
cp
-
JUNGSUNG
next
elsif
cp
>=
JONGSUNG
&&
cp
<
JONGSUNG
+
JONGSUNGS
pend
<<
cp
-
JONGSUNG
next
else
omap
[
-
1
]
=
omap
[
-
1
]
+
1
ret
<<
[
NFC_BEGIN
+
pend
[
0
]
*
JJCOUNT
+
(
pend
[
1
]
||
0
)
*
JONGSUNGS
+
(
pend
[
2
]
||
0
)].
pack
(
'U*'
)
pend
.
clear
end
end
if
cp
>=
CHOSUNG
&&
cp
<
CHOSUNG
+
CHOSUNGS
pend
<<
cp
-
CHOSUNG
else
ret
<<
c
end
end
return
[
ret
,
offset
.
map
{
|
o
|
omap
[
o
]
||
(
omap
.
last
+
1
)
}]
end
end
def
convert_query
q
UConv
.
nfd
(
q
).
split
(
//
)
end
def
convert_item
item
UConv
.
nfc
(
*
item
)
end
else
def
convert_query
q
q
.
split
(
//
)
end
def
convert_item
item
item
end
end
def
emit
event
@mtx
.
synchronize
do
@events
[
event
]
=
yield
...
...
@@ -124,8 +204,8 @@ end
if
RUBY_VERSION
.
split
(
'.'
).
map
{
|
e
|
e
.
rjust
(
3
,
'0'
)
}.
join
>
'001009'
def
ulen
str
expr
=
'\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}'
str
.
gsub
(
Regexp
.
new
(
expr
)
,
' '
).
length
@urx
||=
Regexp
.
new
'\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}'
str
.
gsub
(
@urx
,
' '
).
length
end
else
def
ulen
str
...
...
@@ -226,7 +306,7 @@ searcher = Thread.new {
events
.
delete
:new
q
=
events
.
delete
(
:key
)
||
q
regexp
=
q
.
empty?
?
nil
:
Regexp
.
new
(
q
.
split
(
//
).
inject
(
''
)
{
|
sum
,
e
|
Regexp
.
new
(
convert_query
(
q
).
inject
(
''
)
{
|
sum
,
e
|
e
=
Regexp
.
escape
e
sum
<<
"
#{
e
}
[^
#{
e
}
]*?"
},
@rxflag
)
...
...
@@ -301,7 +381,7 @@ searcher = Thread.new {
matches
[
0
,
max_items
].
each_with_index
do
|
item
,
idx
|
next
if
!
new_search
&&
!
((
vcursor
-
1
)
..
(
vcursor
+
1
)).
include?
(
idx
)
line
,
offset
=
item
line
,
offset
=
convert_item
item
row
=
cursor_y
-
idx
-
2
chosen
=
idx
==
vcursor
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment