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
e34c7c00
Unverified
Commit
e34c7c00
authored
5 years ago
by
Jack Bates
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Test multi-line C-r (#1892)
parent
7c447bbd
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
test/test_go.rb
+34
-32
34 additions, 32 deletions
test/test_go.rb
with
34 additions
and
32 deletions
test/test_go.rb
+
34
−
32
View file @
e34c7c00
...
...
@@ -87,8 +87,8 @@ class Tmux
attr_reader
:win
def
initialize
(
shell
=
:bash
)
@win
=
go
(
"
new-window -d -P -F
'
#I
' '
#{
Shell
.
send
(
shell
)
}
'"
).
first
go
(
"
set-window-option -t
#{
@win
}
pane-base-index 0
"
)
@win
=
go
(
%W[
new-window -d -P -F #I
#{
Shell
.
send
(
shell
)
}
]
).
first
go
(
%W[
set-window-option -t
#{
@win
}
pane-base-index 0
]
)
return
unless
shell
==
:fish
send_keys
(
'function fish_prompt; end; clear'
,
:Enter
)
...
...
@@ -96,30 +96,19 @@ class Tmux
end
def
kill
go
(
"
kill-window -t
#{
win
}
2> /dev/null"
)
go
(
%W[
kill-window -t
#{
win
}
]
)
end
def
send_keys
(
*
args
)
target
=
if
args
.
last
.
is_a?
(
Hash
)
hash
=
args
.
pop
go
(
"
select-window -t
#{
win
}
"
)
go
(
%W[
select-window -t
#{
win
}
]
)
"
#{
win
}
.
#{
hash
[
:pane
]
}
"
else
win
end
enum
=
(
args
+
[
nil
]).
each_cons
(
2
)
loop
do
pair
=
enum
.
next
if
pair
.
first
==
:Escape
arg
=
pair
.
compact
.
map
{
|
key
|
%("
#{
key
}
")
}.
join
(
' '
)
go
(
%(send-keys -t
#{
target
}
#{
arg
}
)
)
enum
.
next
if
pair
.
last
else
go
(
%(send-keys -t
#{
target
}
"
#{
pair
.
first
}
")
)
end
break
unless
pair
.
last
end
go
(
%W[send-keys -t
#{
target
}
]
+
args
.
map
(
&
:to_s
))
end
def
paste
(
str
)
...
...
@@ -127,7 +116,7 @@ class Tmux
end
def
capture
(
pane
=
0
)
go
(
"
capture-pane -p -t
#{
win
}
.
#{
pane
}
"
)
go
(
%W[
capture-pane -p -t
#{
win
}
.
#{
pane
}
]
).
reverse
.
drop_while
(
&
:empty?
).
reverse
end
def
until
(
refresh
=
false
,
pane
=
0
)
...
...
@@ -189,8 +178,8 @@ class Tmux
private
def
go
(
*
args
)
`tmux
#{
args
.
join
' '
}
`
.
split
(
$INPUT_RECORD_SEPARATOR
)
def
go
(
args
)
IO
.
popen
([
'tmux'
]
+
args
)
{
|
io
|
io
.
readlines
(
chomp:
true
)
}
end
end
...
...
@@ -501,7 +490,7 @@ class TestGoFZF < TestBase
end
def
test_sync
tmux
.
send_keys
"seq 1 100 |
#{
fzf!
:multi
}
| awk '{print
\\
$1
\\
$1}' |
#{
fzf
:sync
}
"
,
:Enter
tmux
.
send_keys
"seq 1 100 |
#{
fzf!
:multi
}
| awk '{print $1 $1}' |
#{
fzf
:sync
}
"
,
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
1
]
==
'>'
}
tmux
.
send_keys
9
tmux
.
until
{
|
lines
|
lines
[
-
2
]
==
' 19/100'
}
...
...
@@ -782,7 +771,7 @@ class TestGoFZF < TestBase
end
def
test_invalid_cache_query_type
command
=
%[(echo 'foo
\\
$bar'; echo 'barfoo'; echo 'foo^bar'; echo
\\
"foo'1-2
\\
"; seq 100) |
#{
fzf
}
]
command
=
%[(echo 'foo$bar'; echo 'barfoo'; echo 'foo^bar'; echo "foo'1-2"; seq 100) |
#{
fzf
}
]
# Suffix match
tmux
.
send_keys
command
,
:Enter
...
...
@@ -941,7 +930,7 @@ class TestGoFZF < TestBase
def
test_execute
output
=
'/tmp/fzf-test-execute'
opts
=
%[--bind
\\
"alt-a:execute(echo /{}/ >>
#{
output
}
),alt-b:execute[echo /{}{}/ >>
#{
output
}
],C:execute:echo /{}{}{}/ >>
#{
output
}
\\
"]
opts
=
%[--bind "alt-a:execute(echo /{}/ >>
#{
output
}
),alt-b:execute[echo /{}{}/ >>
#{
output
}
],C:execute:echo /{}{}{}/ >>
#{
output
}
"]
wait
=
->
(
exp
)
{
tmux
.
until
{
|
lines
|
lines
[
-
2
].
include?
exp
}
}
writelines
tempname
,
%w[foo'bar foo"bar foo$bar]
tmux
.
send_keys
"cat
#{
tempname
}
|
#{
fzf
opts
}
; sync"
,
:Enter
...
...
@@ -980,7 +969,7 @@ class TestGoFZF < TestBase
def
test_execute_multi
output
=
'/tmp/fzf-test-execute-multi'
opts
=
%[--multi --bind
\\
"alt-a:execute-multi(echo {}/{+} >>
#{
output
}
; sync)
\\
"]
opts
=
%[--multi --bind "alt-a:execute-multi(echo {}/{+} >>
#{
output
}
; sync)"]
writelines
tempname
,
%w[foo'bar foo"bar foo$bar foobar]
tmux
.
send_keys
"cat
#{
tempname
}
|
#{
fzf
opts
}
"
,
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
2
].
include?
'4/4'
}
...
...
@@ -1166,7 +1155,7 @@ class TestGoFZF < TestBase
end
def
test_header
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header
\
\\"\\
$(head -5
#{
FILE
}
)
\
\\
"
"
}
"
,
:Enter
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header
\
"
$(head -5
#{
FILE
}
)
\"
"
}
"
,
:Enter
header
=
File
.
readlines
(
FILE
).
take
(
5
).
map
(
&
:strip
)
tmux
.
until
do
|
lines
|
lines
[
-
2
].
include?
(
'100/100'
)
&&
...
...
@@ -1176,7 +1165,7 @@ class TestGoFZF < TestBase
end
def
test_header_reverse
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header
=
\\\"\\
$(head -5
#{
FILE
}
)
\
\\
"
--reverse"
}
"
,
:Enter
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header
\"
$(head -5
#{
FILE
}
)
\"
--reverse"
}
"
,
:Enter
header
=
File
.
readlines
(
FILE
).
take
(
5
).
map
(
&
:strip
)
tmux
.
until
do
|
lines
|
lines
[
1
].
include?
(
'100/100'
)
&&
...
...
@@ -1186,7 +1175,7 @@ class TestGoFZF < TestBase
end
def
test_header_reverse_list
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header
=
\\\"\\
$(head -5
#{
FILE
}
)
\
\\
"
--layout=reverse-list"
}
"
,
:Enter
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header
\"
$(head -5
#{
FILE
}
)
\"
--layout=reverse-list"
}
"
,
:Enter
header
=
File
.
readlines
(
FILE
).
take
(
5
).
map
(
&
:strip
)
tmux
.
until
do
|
lines
|
lines
[
-
2
].
include?
(
'100/100'
)
&&
...
...
@@ -1196,7 +1185,7 @@ class TestGoFZF < TestBase
end
def
test_header_and_header_lines
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header-lines 10 --header
\
\\"\\
$(head -5
#{
FILE
}
)
\
\\
"
"
}
"
,
:Enter
tmux
.
send_keys
"seq 100 |
#{
fzf
"--header-lines 10 --header
\
"
$(head -5
#{
FILE
}
)
\"
"
}
"
,
:Enter
header
=
File
.
readlines
(
FILE
).
take
(
5
).
map
(
&
:strip
)
tmux
.
until
do
|
lines
|
lines
[
-
2
].
include?
(
'90/90'
)
&&
...
...
@@ -1206,7 +1195,7 @@ class TestGoFZF < TestBase
end
def
test_header_and_header_lines_reverse
tmux
.
send_keys
"seq 100 |
#{
fzf
"--reverse --header-lines 10 --header
\
\\"\\
$(head -5
#{
FILE
}
)
\
\\
"
"
}
"
,
:Enter
tmux
.
send_keys
"seq 100 |
#{
fzf
"--reverse --header-lines 10 --header
\
"
$(head -5
#{
FILE
}
)
\"
"
}
"
,
:Enter
header
=
File
.
readlines
(
FILE
).
take
(
5
).
map
(
&
:strip
)
tmux
.
until
do
|
lines
|
lines
[
1
].
include?
(
'90/90'
)
&&
...
...
@@ -1216,7 +1205,7 @@ class TestGoFZF < TestBase
end
def
test_header_and_header_lines_reverse_list
tmux
.
send_keys
"seq 100 |
#{
fzf
"--layout=reverse-list --header-lines 10 --header
\
\\"\\
$(head -5
#{
FILE
}
)
\
\\
"
"
}
"
,
:Enter
tmux
.
send_keys
"seq 100 |
#{
fzf
"--layout=reverse-list --header-lines 10 --header
\
"
$(head -5
#{
FILE
}
)
\"
"
}
"
,
:Enter
header
=
File
.
readlines
(
FILE
).
take
(
5
).
map
(
&
:strip
)
tmux
.
until
do
|
lines
|
lines
[
-
2
].
include?
(
'90/90'
)
&&
...
...
@@ -1327,7 +1316,7 @@ class TestGoFZF < TestBase
def
test_exitstatus_empty
{
'99'
=>
'0'
,
'999'
=>
'1'
}.
each
do
|
query
,
status
|
tmux
.
send_keys
"seq 100 |
#{
FZF
}
-q
#{
query
}
; echo --
\\
$?--"
,
:Enter
tmux
.
send_keys
"seq 100 |
#{
FZF
}
-q
#{
query
}
; echo --$?--"
,
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
2
]
=~
%r{ [10]/100}
}
tmux
.
send_keys
:Enter
tmux
.
until
{
|
lines
|
lines
.
last
.
include?
"--
#{
status
}
--"
}
...
...
@@ -1472,7 +1461,7 @@ class TestGoFZF < TestBase
end
def
test_preview_hidden
tmux
.
send_keys
%(seq 1000 |
#{
FZF
}
--preview 'echo {{}-{}-
\\
$FZF_PREVIEW_LINES-
\\
$FZF_PREVIEW_COLUMNS}' --preview-window down:1:hidden --bind ?:toggle-preview)
,
:Enter
tmux
.
send_keys
%(seq 1000 |
#{
FZF
}
--preview 'echo {{}-{}-$FZF_PREVIEW_LINES-$FZF_PREVIEW_COLUMNS}' --preview-window down:1:hidden --bind ?:toggle-preview)
,
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
1
]
==
'>'
}
tmux
.
send_keys
'?'
tmux
.
until
{
|
lines
|
lines
[
-
2
]
=~
/ {1-1-1-[0-9]+}/
}
...
...
@@ -1849,6 +1838,19 @@ module TestShell
tmux
.
until
{
|
lines
|
lines
[
-
1
]
==
'3rd'
}
end
def
test_ctrl_r_multiline
tmux
.
send_keys
'echo "foo'
,
:Enter
,
'bar"'
,
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
2
..-
1
]
==
[
'foo'
,
'bar'
]
}
tmux
.
send_keys
'C-r'
tmux
.
until
{
|
lines
|
lines
[
-
1
]
==
'>'
}
tmux
.
send_keys
'foo bar'
tmux
.
until
{
|
lines
|
lines
[
-
3
].
end_with?
'bar"'
}
tmux
.
send_keys
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
1
].
end_with?
'bar"'
}
tmux
.
send_keys
:Enter
tmux
.
until
{
|
lines
|
lines
[
-
2
..-
1
]
==
[
'foo'
,
'bar'
]
}
end
def
test_ctrl_r_abort
skip
"doesn't restore the original line when search is aborted pre Bash 4"
if
shell
==
:bash
&&
/(?<= version )\d+/
.
match
(
`
#{
Shell
.
bash
}
--version`
).
to_s
.
to_i
<
4
tmux
.
send_keys
'foo'
...
...
@@ -1988,7 +1990,7 @@ module CompletionTest
end
def
test_custom_completion
tmux
.
send_keys
'_fzf_compgen_path() { echo "
\
$1"; seq 10; }'
,
:Enter
tmux
.
send_keys
'_fzf_compgen_path() { echo "$1"; seq 10; }'
,
:Enter
tmux
.
prepare
tmux
.
send_keys
'ls /tmp/**'
,
:Tab
tmux
.
until
{
|
lines
|
lines
.
match_count
==
11
}
...
...
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