Skip to content
Myr

tmux_test.go

This file

Path

src/tmux_test.go

53 lines · 1.2 KiB · Go

Last changed by

Escape trailing semicolon in tmux command argumentJunegunn Choibefore adoption5763168

History of this file

Take it

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

lines 1–4why, one step back
1package fzf
23import "testing"4

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

line 5why, one step back
5func TestEscapeTmuxFormat(t *testing.T) {

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

lines 6–12why, one step back
6 for _, tc := range []struct {
7 given string8 expected string9 }{10 {"", ""},11 {" fzf ", " fzf "},12 {"100%", "100%"},

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

lines 13–18why, one step back
13 // '#[' would be taken as a style directive when the label is drawn
14 {"#[fg=red]x", "##[fg=red]x"},15 // '#{' is already literal in a substituted value, but doubling it16 // keeps a label that fzf renders itself looking the same17 {"#{pane_id}", "##{pane_id}"},18 {" C# notes #S ", " C## notes ##S "},

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

lines 19–20why, one step back
19 {";", `\;`},
20 {"; rm", "; rm"},

Escape trailing semicolon in tmux command argumentJunegunn Choibefore adoption5763168

line 21why, one step back
21 {"C#;", `C##\;`},

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

line 22why, one step back
22 } {

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

line 23why, one step back
23 if actual := escapeTmuxFormat(tc.given); actual != tc.expected {

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

lines 24–28why, one step back
24 t.Errorf("expected %q, got %q", tc.expected, actual)
25 }26 }27}28

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

line 29why, one step back
29func TestEscapeTmuxSeparator(t *testing.T) {

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

lines 30–33why, one step back
30 for _, tc := range []struct {
31 given string32 expected string33 }{

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

lines 34–38why, one step back
34 {"", ""},
35 {" fzf ", " fzf "},36 {"#", "#"},37 {"#{pane_id}", "#{pane_id}"},38 {"100%", "100%"},

Escape trailing semicolon in tmux command argumentJunegunn Choibefore adoption5763168

lines 39–40why, one step back
39 // tmux drops a trailing ';' and everything after it, so only that
40 // one is escaped

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

line 41why, one step back
41 {";", `\;`},

Escape trailing semicolon in tmux command argumentJunegunn Choibefore adoption5763168

lines 42–44why, one step back
42 {"abc;", `abc\;`},
43 {";;", `;\;`},44 {`foo\;`, `foo\\;`},

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

lines 45–46why, one step back
45 {"; rm", "; rm"},
46 {" ; ", " ; "},

Escape trailing semicolon in tmux command argumentJunegunn Choibefore adoption5763168

line 47why, one step back
47 {"a;b", "a;b"},

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

line 48why, one step back
48 } {

Separate floating pane border label from pane titleJunegunn Choibefore adoption50e6c02

line 49why, one step back
49 if actual := escapeTmuxSeparator(tc.given); actual != tc.expected {

Set --border-label as the title of the tmux floating pane (#4853)Junegunn Choibefore adoption77e6394

lines 50–53why, one step back
50 t.Errorf("expected %q, got %q", tc.expected, actual)
51 }52 }53}