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
c326e363
Commit
c326e363
authored
11 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Premature optimization is root of all fun
parent
d1298b8f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fzf
+25
-28
25 additions, 28 deletions
fzf
with
25 additions
and
28 deletions
fzf
+
25
−
28
View file @
c326e363
...
...
@@ -104,7 +104,7 @@ when /darwin/
ret
end
def
self
.
nfc
str
,
b
,
e
def
self
.
nfc
str
,
b
=
0
,
e
=
0
ret
=
''
omap
=
[]
pend
=
[]
...
...
@@ -344,10 +344,9 @@ searcher = Thread.new {
if
wait_for_completion
@smtx
.
synchronize
do
print_info
false
,
" +
#{
@new
.
length
}
"
print_input
refresh
sleep
0.1
end
sleep
((
delay
=
[
20
,
delay
+
5
].
min
)
*
0.01
)
next
end
...
...
@@ -359,11 +358,14 @@ searcher = Thread.new {
if
new_search
&&
!
@lists
.
empty?
events
.
delete
:new
q
=
events
.
delete
(
:key
)
||
q
regexp
=
q
.
empty?
?
nil
:
Regexp
.
new
(
convert_query
(
q
).
inject
(
''
)
{
|
sum
,
e
|
unless
q
.
empty?
q
=
q
.
downcase
if
@rxflag
!=
0
regexp
=
Regexp
.
new
(
convert_query
(
q
).
inject
(
''
)
{
|
sum
,
e
|
e
=
Regexp
.
escape
e
sum
<<
"
#{
e
}
[^
#{
e
}
]*?"
},
@rxflag
)
end
matches
=
fcache
[
q
]
||=
begin
...
...
@@ -380,14 +382,14 @@ searcher = Thread.new {
}
break
if
skip
if
!
q
.
empty?
&&
progress
<
100
&&
Time
.
now
-
started_at
>
0.5
@smtx
.
synchronize
do
print_info
true
,
" (
#{
progress
}
%)"
refresh
found
.
concat
(
cache
[
q
]
||=
q
.
empty?
?
list
:
begin
if
progress
<
100
&&
Time
.
now
-
started_at
>
0.5
@smtx
.
synchronize
do
print_info
true
,
" (
#{
progress
}
%)"
refresh
end
end
end
found
.
concat
(
cache
[
q
]
||=
begin
prefix
,
suffix
=
@query
[
0
,
@cursor_x
],
@query
[
@cursor_x
..-
1
]
||
''
prefix_cache
=
suffix_cache
=
nil
...
...
@@ -401,13 +403,9 @@ searcher = Thread.new {
partial_cache
=
[
prefix_cache
,
suffix_cache
].
compact
.
sort_by
{
|
e
|
e
.
length
}.
first
(
partial_cache
?
partial_cache
.
map
{
|
e
|
e
.
first
}
:
list
).
map
{
|
line
|
if
regexp
# Ignore errors: e.g. invalid byte sequence in UTF-8
md
=
line
.
match
(
regexp
)
rescue
nil
md
?
[
line
,
*
md
.
offset
(
0
)]
:
nil
else
[
line
,
0
,
0
]
end
# Ignore errors: e.g. invalid byte sequence in UTF-8
md
=
line
.
match
(
regexp
)
rescue
nil
md
&&
[
line
,
*
md
.
offset
(
0
)]
}.
compact
end
)
end
...
...
@@ -419,7 +417,7 @@ searcher = Thread.new {
if
@sort
&&
mcount
<=
@sort
matches
.
replace
matches
.
sort_by
{
|
triple
|
line
,
b
,
e
=
triple
[
e
-
b
,
line
.
length
,
line
]
[
b
?
(
e
-
b
)
:
0
,
line
.
length
,
line
]
}
end
end
#new_search
...
...
@@ -491,10 +489,9 @@ searcher = Thread.new {
end
print_info
if
!
@lists
.
empty?
||
events
[
:loaded
]
print_input
refresh
end
end
end
#while
rescue
Exception
=>
e
main
.
raise
e
end
...
...
@@ -536,6 +533,13 @@ begin
actions
[
ctrl
(
:p
)]
=
actions
[
ctrl
(
:k
)]
while
true
# Update user input
@smtx
.
synchronize
do
@cursor_x
=
cursor
print_input
refresh
end
ord
=
tty
.
getc
.
ord
if
ord
==
27
ord
=
tty
.
getc
.
ord
...
...
@@ -560,13 +564,6 @@ begin
# Dispatch key event
emit
(
:key
)
{
@query
=
input
.
dup
}
# Update user input
@smtx
.
synchronize
do
@cursor_x
=
cursor
print_input
refresh
end
end
ensure
C
.
close_screen
...
...
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