Skip to content
Myr

Fix inline header/footer border color when falling back to line

Before adoption: this commit came in with the history the project adopted, so no landing records it.

InitTheme was called before the runtime coerced BorderInline to BorderLine, so HeaderBorder / FooterBorder inherited from ListBorder even when the effective shape was 'line'. Mirror the coercion so color inheritance matches the rendered shape.

authored by Junegunn Choi · committed by Junegunn Choi · parent d754cfa · Browse files · 3 files+37 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+37 added−3 removed

  • tests:+30 added−0 removed
  • other:+7 added−3 removed

3 files+37 added−3 removed

modified:src/terminal.go+7 added-3 removed
1165 unmodified lines
1166 baseTheme := opts.BaseTheme1167 if baseTheme == nil {1168 baseTheme = renderer.DefaultTheme()1169 }1170 // This should be called before accessing tui.Color*1171 headerInline := opts.HeaderBorderShape == tui.BorderInline || opts.HeaderLinesShape == tui.BorderInline1172 footerInline := opts.FooterBorderShape == tui.BorderInline1170 // If the list border can't host an inline separator, the runtime later coerces1171 // BorderInline to BorderLine. Mirror that here so theme color inheritance matches1172 // the final rendering rather than the user's requested shape.1173 inlineListSupported := opts.ListBorderShape.HasTop() && opts.ListBorderShape.HasBottom()1174 headerInline := inlineListSupported && (opts.HeaderBorderShape == tui.BorderInline || opts.HeaderLinesShape == tui.BorderInline)1175 footerInline := inlineListSupported && opts.FooterBorderShape == tui.BorderInline1176 hasHeader := opts.HeaderBorderShape.Visible() || opts.HeaderLinesShape.Visible()1177 // This should be called before accessing tui.Color*1178 tui.InitTheme(opts.Theme, baseTheme, opts.Bold, opts.Black, opts.InputBorderShape.Visible(), hasHeader, headerInline, footerInline)11791180 // Gutter character1181 var gutterChar, gutterRawChar string
7004 unmodified lines
modified:test/lib/common.rb+5 added
128 unmodified lines
129 def capture130 go(%W[capture-pane -p -J -t #{win}]).map(&:rstrip).reverse.drop_while(&:empty?).reverse131 end132133 # Raw pane capture with ANSI escape sequences preserved.134 def capture_ansi135 go(%W[capture-pane -p -J -e -t #{win}])136 end137138 # 3-bit ANSI bg code (40..47) -> color name used in --color options.139 BG_NAMES = %w[black red green yellow blue magenta cyan white].freeze140141 # Parse `tmux capture-pane -e` output into per-row bg ranges. Each row is an
192 unmodified lines
modified:test/test_layout.rb+25 added
1464 unmodified lines
1465 assert(lines.none? { |l| l.match?(/[╭╮╰╯┌┐└┘├┤]/) }, "unexpected frame glyphs: #{lines.inspect}")1466 tmux.send_keys 'Escape'1467 end14681469 # Regression: when --header-border=inline falls back to `line` because the1470 # list border can't host an inline separator, the header-border color must1471 # inherit from `border`, not `list-border`. The effective shape is `line`,1472 # so color inheritance must match what `line` rendering would use.1473 def test_inline_fallback_does_not_inherit_list_border_color1474 # Marker attribute (bold) on list-border. If HeaderBorder wrongly inherits1475 # from ListBorder, the header separator characters will carry the bold1476 # attribute. --info=hidden and --no-separator strip other separator lines1477 # so the only row of `─` chars is the header separator.1478 tmux.send_keys %(seq 5 | #{FZF} --list-border=none --header HEADER --header-border=inline --info=hidden --no-separator --color=bg:-1,list-border:red:bold), :Enter1479 sep_row = nil1480 tmux.until do |_|1481 sep_row = tmux.capture_ansi.find do |row|1482 stripped = row.gsub(/\e\[[\d;]*m/, '').rstrip1483 stripped.match?(/\A─+\z/)1484 end1485 !sep_row.nil?1486 end1487 # Bold (1) or red fg (31) on the header separator means it inherited from1488 # list-border even though the effective shape is `line` (non-inline).1489 refute_match(/\e\[(?:[\d;]*;)?(?:1|31)(?:;[\d;]*)?m─/, sep_row,1490 "header separator inherited list-border attr: #{sep_row.inspect}")1491 tmux.send_keys 'Escape'1492 end14931494 # Invalid inline combinations must be rejected at startup.1495 def test_inline_rejected_on_unsupported_options1496 [1497 ['--border=inline', 'inline border is only supported'],
78 unmodified lines