Skip to content
Myr

Allow removing header line with change-header and transform-header

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

If the new header is an empty string. fzf --header loading --bind 'start:reload:sleep 3; ls' --bind 'load:change-header:' fzf --header loading --bind 'start:reload:sleep 3; ls' --bind 'load:transform-header:'

authored by Junegunn Choi · committed by Junegunn Choi · parent 70bf8bc · Browse files · 2 files+13 added−11 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+13 added−11 removed

  • tests:+3 added−1 removed
  • other:+10 added−10 removed

2 files+13 added−11 removed

modified:src/terminal.go+10 added-10 removed
1200 unmodified lines
1201 }1202}12031204func (t *Terminal) changeHeader(header string) bool {1205 var lines []string1206 if len(header) > 0 {1205 lines := strings.Split(strings.TrimSuffix(header, "\n"), "\n")1207 lines = strings.Split(strings.TrimSuffix(header, "\n"), "\n")1208 }1209 needFullRedraw := len(t.header0) != len(lines)1210 t.header0 = lines1211 return needFullRedraw1212}
2883 unmodified lines
4096 req(reqList, reqInfo)4097 case actChangeQuery:4098 t.input = []rune(a.a)4099 t.cx = len(t.input)4097 case actTransformHeader:4098 header := t.executeCommand(a.a, false, true, true, false, "")4100 case actChangeHeader, actTransformHeader:4101 header := a.a4102 if a.t == actTransformHeader {4103 header = t.executeCommand(a.a, false, true, true, false, "")4104 }4105 if t.changeHeader(header) {4100 req(reqFullRedraw)4106 req(reqHeader, reqList, reqPrompt, reqInfo)4107 } else {4108 req(reqHeader)4109 }4104 case actChangeHeader:4105 if t.changeHeader(a.a) {4106 req(reqFullRedraw)4107 } else {4108 req(reqHeader)4109 }4110 case actChangeBorderLabel:4111 t.borderLabelOpts.label = a.a4112 if t.border != nil {4113 t.borderLabel, t.borderLabelLen = t.ansiLabelPrinter(a.a, &tui.ColBorderLabel, false)
904 unmodified lines
modified:test/test_go.rb+3 added-1 removed
3356 unmodified lines
3357 tmux.until { assert_block(block, _1) }3358 end33593360 def test_start_on_reload3361 tmux.send_keys %(echo foo | #{FZF} --header Loading --header-lines 1 --bind 'start:reload:sleep 2; echo bar' --bind 'load:change-header:Loaded'), :Enter3361 tmux.send_keys %(echo foo | #{FZF} --header Loading --header-lines 1 --bind 'start:reload:sleep 2; echo bar' --bind 'load:change-header:Loaded' --bind space:change-header:), :Enter3362 tmux.until(timeout: 1) { |lines| assert_includes lines[-3], 'Loading' }3363 tmux.until(timeout: 1) { |lines| refute_includes lines[-4], 'foo' }3364 tmux.until { |lines| assert_includes lines[-3], 'Loaded' }3365 tmux.until { |lines| assert_includes lines[-4], 'bar' }3366 tmux.send_keys :Space3367 tmux.until { |lines| assert_includes lines[-3], 'bar' }3368 end3369end33703371module TestShell
521 unmodified lines