mirror of
https://github.com/junegunn/fzf.git
synced 2026-07-11 19:10:50 +08:00
Set --border-label as the title of the tmux floating pane (#4853)
The pane sets the options itself before running fzf, so that they are
in place no matter how quickly the command exits, targeted at
$TMUX_PANE; the default target would resolve to the active pane of
the session's current window.
- pane-border-format is set to '#{pane_title}' so that the label is
displayed on the border when pane-border-status is enabled;
pane-border-status itself is a window option in released tmux
versions and is left alone
- When a border style is explicitly specified with --border, a popup
is used instead of a floating pane so that the fzf-drawn border is
the only border shown; give 'border-native' to force a floating pane
- 'none' and 'line' are treated as no border; fzf draws no box for
either, so the label is displayed on the native border
- Remove 'border-fzf' which is now redundant; it was never released
- The title is escaped for select-pane -T which expands format
expressions; a lone ';' is escaped as tmux would treat it as a
command separator
- The label is skipped when ANSI stripping leaves an empty string
- --border-label-pos is ignored
- Fix remain-on-exit set on the original pane instead of the floating
pane
This commit is contained in:
+15
-2
@@ -32,7 +32,20 @@ class TestTmux < TestInteractive
|
||||
tmux.until { |lines| assert lines.any_include?('code:130') }
|
||||
end
|
||||
|
||||
def test_border_fzf_falls_back_to_popup
|
||||
def test_floating_pane_border_label
|
||||
tmux.send_keys "seq 100 | #{fzf(%(--popup center,80% --margin 0 --border-label ' #fzf-label 100% '))}", :Enter
|
||||
tmux.until { |lines| assert_equal 100, lines.item_count }
|
||||
pane = floating_pane
|
||||
refute_nil pane
|
||||
title = IO.popen(['tmux', 'display-message', '-p', '-t', pane, "\#{pane_title}"], &:read)
|
||||
assert_equal ' #fzf-label 100% ', title.chomp
|
||||
format = IO.popen(['tmux', 'show-options', '-p', '-t', pane, 'pane-border-format'], &:read)
|
||||
assert_includes format, "\#{pane_title}"
|
||||
tmux.send_keys :Enter
|
||||
assert_equal '1', fzf_output
|
||||
end
|
||||
|
||||
def test_explicit_border_falls_back_to_popup
|
||||
# display-popup requires an attached client, which the test environment
|
||||
# may not have; intercept it with a tmux shim on PATH
|
||||
dir = Dir.mktmpdir
|
||||
@@ -47,7 +60,7 @@ class TestTmux < TestInteractive
|
||||
exec #{real.shellescape} "$@"
|
||||
SH
|
||||
FileUtils.chmod(0o755, shim)
|
||||
tmux.send_keys "seq 100 | PATH=#{dir.shellescape}:$PATH #{FZF} --popup center,border-fzf", :Enter
|
||||
tmux.send_keys "seq 100 | PATH=#{dir.shellescape}:$PATH #{FZF} --popup center --border rounded", :Enter
|
||||
tmux.until { |lines| assert lines.any_include?('popup-used') }
|
||||
refute floating_pane
|
||||
ensure
|
||||
|
||||
Reference in New Issue
Block a user