Skip to content
Myr

Redraw when change-header changes line count

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

The inline header slot's row budget depends on header content length, but resizeIfNeeded() tolerates a shorter-than-wanted inline window, so the stale slot stays. Drive a redraw on length change to re-run the layout.

authored by Junegunn Choi · committed by Junegunn Choi · parent dd7a081 · Browse files · 2 files+22 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

2 files+22 added−3 removed

  • tests:+13 added−0 removed
  • other:+9 added−3 removed

2 files+22 added−3 removed

modified:src/terminal.go+9 added-3 removed
6779 unmodified lines
6780 t.input = []rune(a.a)6781 t.cx = len(t.input)6782 case actChangeHeader, actTransformHeader, actBgTransformHeader:6783 capture(false, func(header string) {6784 // When a dedicated header window is not used, we may need to6785 // update other elements as well.6784 if t.changeHeader(header) {6785 // resizeIfNeeded() tolerates a shorter-than-wanted inline6786 // window, so a length change can leave the inline slot6787 // stale. Force a redraw to re-run the layout. Non-inline6788 // shapes are handled by resizeIfNeeded.6789 if t.headerBorderShape == tui.BorderInline {6790 req(reqRedraw)6791 } else {6787 req(reqList, reqPrompt, reqInfo)6792 req(reqList, reqPrompt, reqInfo)6793 }6794 }6795 req(reqHeader)6796 })6797 case actChangeFooter, actTransformFooter, actBgTransformFooter:
1400 unmodified lines
modified:test/test_layout.rb+13 added
1525 unmodified lines
1526 one_idx && input_idx && one_idx < input_idx1527 end1528 end15291530 # Regression: with --header-border=inline and --header-lines but no1531 # --header, the inline slot was sized for header-lines only. After1532 # change-header added a main header line, resizeIfNeeded tolerated the1533 # too-small slot, so the header-lines line got displaced and disappeared.1534 def test_inline_change_header_grows_slot1535 tmux.send_keys %(seq 5 | #{FZF} --style full --header-lines 1 --header-border inline --bind space:change-header:tada), :Enter1536 tmux.until { |lines| lines.any_include?(/\A│\s+1\s+│\z/) }1537 tmux.send_keys ' '1538 tmux.until do |lines|1539 lines.any_include?(/\A│\s+1\s+│\z/) && lines.any_include?(/\A│\s+tada\s+│\z/)1540 end1541 end15421543 # Invalid inline combinations must be rejected at startup.1544 def test_inline_rejected_on_unsupported_options1545 [1546 ['--border=inline', 'inline border is only supported'],
76 unmodified lines