mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-12 19:07:00 +08:00
Clear border text of the floating pane when no label is given
This commit is contained in:
+11
-6
@@ -120,15 +120,18 @@ func runTmuxFloatingPane(argStr string, dir string, windowWidth int, windowHeigh
|
|||||||
|
|
||||||
// Set --border-label as the title of the floating pane, and as its
|
// Set --border-label as the title of the floating pane, and as its
|
||||||
// pane-border-format so that it is displayed on the border when
|
// pane-border-format so that it is displayed on the border when
|
||||||
// pane-border-status is enabled. pane-border-format is pane-scoped,
|
// pane-border-status is enabled. Without a label, the border text
|
||||||
|
// is cleared so that the default pane status content (e.g. the
|
||||||
|
// pane title) is not shown. pane-border-format is pane-scoped,
|
||||||
// but pane-border-status is a window option that only becomes
|
// but pane-border-status is a window option that only becomes
|
||||||
// pane-scoped in the next release of tmux, so it is left alone.
|
// pane-scoped in the next release of tmux, so it is left alone.
|
||||||
// https://github.com/tmux/tmux/commit/7a18fa281db3
|
// https://github.com/tmux/tmux/commit/7a18fa281db3
|
||||||
// --border-label-pos is ignored.
|
// --border-label-pos is ignored.
|
||||||
// Skipped when fzf draws its own border with the label on it.
|
// The label is left to fzf when it draws its own border with the
|
||||||
// '--border=none' is included; fzf would not display the label, but
|
// label on it. '--border=none' is not the case; fzf would not
|
||||||
// the native border of a floating pane cannot be removed, so
|
// display the label, but the native border of a floating pane
|
||||||
// display the label on it nonetheless.
|
// cannot be removed, so display the label on it nonetheless.
|
||||||
|
format := ""
|
||||||
if opts.BorderLabel.label != "" &&
|
if opts.BorderLabel.label != "" &&
|
||||||
(opts.BorderShape == tui.BorderUndefined || opts.BorderShape == tui.BorderLine ||
|
(opts.BorderShape == tui.BorderUndefined || opts.BorderShape == tui.BorderLine ||
|
||||||
opts.BorderShape == tui.BorderNone) {
|
opts.BorderShape == tui.BorderNone) {
|
||||||
@@ -139,9 +142,11 @@ func runTmuxFloatingPane(argStr string, dir string, windowWidth int, windowHeigh
|
|||||||
escapeSingleQuote(escapeTmuxTitle(label)))
|
escapeSingleQuote(escapeTmuxTitle(label)))
|
||||||
// The title is displayed verbatim; substituted values are
|
// The title is displayed verbatim; substituted values are
|
||||||
// not expanded again
|
// not expanded again
|
||||||
setup += `tmux set-option -p -t "$TMUX_PANE" pane-border-format '#{pane_title}' 2> /dev/null; `
|
format = "#{pane_title}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setup += fmt.Sprintf(`tmux set-option -p -t "$TMUX_PANE" pane-border-format %s 2> /dev/null; `,
|
||||||
|
escapeSingleQuote(format))
|
||||||
paneCmd := fmt.Sprintf("%s%s %s; echo $? > %s; tmux wait-for -S %s",
|
paneCmd := fmt.Sprintf("%s%s %s; echo $? > %s; tmux wait-for -S %s",
|
||||||
setup, escapeSingleQuote(sh), escapeSingleQuote(temp), code, signal)
|
setup, escapeSingleQuote(sh), escapeSingleQuote(temp), code, signal)
|
||||||
// Unzoom the window first; creating a floating pane over a zoomed
|
// Unzoom the window first; creating a floating pane over a zoomed
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ class TestTmux < TestInteractive
|
|||||||
def test_floating_pane
|
def test_floating_pane
|
||||||
tmux.send_keys "seq 100 | #{fzf('--popup center,80% --margin 0')}", :Enter
|
tmux.send_keys "seq 100 | #{fzf('--popup center,80% --margin 0')}", :Enter
|
||||||
tmux.until { |lines| assert_equal 100, lines.item_count }
|
tmux.until { |lines| assert_equal 100, lines.item_count }
|
||||||
|
# Border text is cleared when no label is given
|
||||||
|
format = IO.popen(['tmux', 'show-options', '-p', '-t', floating_pane, 'pane-border-format'], &:read)
|
||||||
|
assert_includes format, "''"
|
||||||
tmux.send_keys '99'
|
tmux.send_keys '99'
|
||||||
tmux.until { |lines| assert_equal 1, lines.match_count }
|
tmux.until { |lines| assert_equal 1, lines.match_count }
|
||||||
tmux.send_keys :Enter
|
tmux.send_keys :Enter
|
||||||
|
|||||||
Reference in New Issue
Block a user