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
dea60b11
Commit
dea60b11
authored
9 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Only consider the lengths of the relevant parts when --nth is set
parent
5e90f0a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/item.go
+10
-1
10 additions, 1 deletion
src/item.go
test/test_go.rb
+26
-0
26 additions, 0 deletions
test/test_go.rb
with
36 additions
and
1 deletion
src/item.go
+
10
−
1
View file @
dea60b11
...
...
@@ -63,7 +63,16 @@ func (i *Item) Rank(cache bool) Rank {
var
tiebreak
uint16
switch
rankTiebreak
{
case
byLength
:
tiebreak
=
uint16
(
len
(
*
i
.
text
))
// It is guaranteed that .transformed in not null in normal execution
if
i
.
transformed
!=
nil
{
lenSum
:=
0
for
_
,
token
:=
range
*
i
.
transformed
{
lenSum
+=
len
(
*
token
.
text
)
}
tiebreak
=
uint16
(
lenSum
)
}
else
{
tiebreak
=
uint16
(
len
(
*
i
.
text
))
}
case
byBegin
:
// We can't just look at i.offsets[0][0] because it can be an inverse term
tiebreak
=
uint16
(
minBegin
)
...
...
This diff is collapsed.
Click to expand it.
test/test_go.rb
+
26
−
0
View file @
dea60b11
...
...
@@ -501,6 +501,32 @@ class TestGoFZF < TestBase
assert_equal
input
,
`cat
#{
tempname
}
|
#{
FZF
}
-f"!z" -x --tiebreak end`
.
split
(
$/
)
end
def
test_tiebreak_length_with_nth
input
=
%w[
1:hell
123:hello
12345:he
1234567:h
]
writelines
tempname
,
input
output
=
%w[
1:hell
12345:he
123:hello
1234567:h
]
assert_equal
output
,
`cat
#{
tempname
}
|
#{
FZF
}
-fh`
.
split
(
$/
)
output
=
%w[
1234567:h
12345:he
1:hell
123:hello
]
assert_equal
output
,
`cat
#{
tempname
}
|
#{
FZF
}
-fh -n2 -d:`
.
split
(
$/
)
end
def
test_invalid_cache
tmux
.
send_keys
"(echo d; echo D; echo x) |
#{
fzf
'-q d'
}
"
,
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
2
].
include?
'2/3'
}
...
...
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