/
githubmirror
/
fzf
Обзор
Документация
Войти
/
githubmirror
/
fzf
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/tmux_test.go
53 строки
1 KB
Junegunn Choi
Escape trailing semicolon in tmux command argument
29 июл 2026, 14:59
Не верифицирован
29 июл 2026, 14:59
5763168
Код
Авторство
О чём код?
package fzf import "testing" func TestEscapeTmuxFormat(t *testing.T) { for _, tc := range []struct { given string expected string }{ {"", ""}, {" fzf ", " fzf "}, {"100%", "100%"}, // '#[' would be taken as a style directive when the label is drawn {"#[fg=red]x", "##[fg=red]x"}, // '#{' is already literal in a substituted value, but doubling it // keeps a label that fzf renders itself looking the same {"#{pane_id}", "##{pane_id}"}, {" C# notes #S ", " C## notes ##S "}, {";", `\;`}, {"; rm", "; rm"}, {"C#;", `C##\;`}, } { if actual := escapeTmuxFormat(tc.given); actual != tc.expected { t.Errorf("expected %q, got %q", tc.expected, actual) } } } func TestEscapeTmuxSeparator(t *testing.T) { for _, tc := range []struct { given string expected string }{ {"", ""}, {" fzf ", " fzf "}, {"#", "#"}, {"#{pane_id}", "#{pane_id}"}, {"100%", "100%"}, // tmux drops a trailing ';' and everything after it, so only that // one is escaped {";", `\;`}, {"abc;", `abc\;`}, {";;", `;\;`}, {`foo\;`, `foo\\;`}, {"; rm", "; rm"}, {" ; ", " ; "}, {"a;b", "a;b"}, } { if actual := escapeTmuxSeparator(tc.given); actual != tc.expected { t.Errorf("expected %q, got %q", tc.expected, actual) } } }