Skip to content
Myr

Fix 'jump' when pointer is empty

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

Fix #4270

authored by Junegunn Choi · committed by Junegunn Choi · parent 77568e1 · Browse files · 2 files+24 added−1 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+24 added−1 removed

  • tests:+18 added−0 removed
  • other:+6 added−1 removed

2 files+24 added−1 removed

modified:src/terminal.go+6 added-1 removed
2753 unmodified lines
2754func (t *Terminal) printItem(result Result, line int, maxLine int, index int, current bool, barRange [2]int) int {2755 item := result.item2756 _, selected := t.selected[item.Index()]2757 label := ""2758 extraWidth := 02759 if t.jumping != jumpDisabled {2760 if index < len(t.jumpLabels) {2761 // Striped2762 current = index%2 == 02762 label = t.jumpLabels[index:index+1] + strings.Repeat(" ", t.pointerLen-1)2763 label = t.jumpLabels[index:index+1] + strings.Repeat(" ", util.Max(0, t.pointerLen-1))2764 if t.pointerLen == 0 {2765 extraWidth = 12766 }2767 }2768 } else if current {2769 label = t.pointer2770 }
20 unmodified lines
2791 }27922793 maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + 1)2794 postTask := func(lineNum int, width int, wrapped bool, forceRedraw bool) {2795 width += extraWidth2796 if (current || selected) && t.highlightLine {2797 color := tui.ColSelected2798 if current {2799 color = tui.ColCurrent
3496 unmodified lines
modified:test/test_core.rb+18 added
825 unmodified lines
826 tmux.send_keys 'C-c'827 tmux.until { |lines| assert(lines.any? { it.include?('jump cancelled at 3') }) }828 end829830 def test_jump_no_pointer831 tmux.send_keys "seq 100 | #{FZF} --pointer= --jump-labels 12345 --bind ctrl-j:jump", :Enter832 tmux.until { |lines| assert_equal 100, lines.match_count }833 tmux.send_keys 'C-j'834 tmux.until { |lines| assert_equal '5 5', lines[-7] }835 tmux.send_keys 'C-c'836 tmux.until { |lines| assert_equal ' 5', lines[-7] }837 end838839 def test_jump_no_pointer_no_marker840 tmux.send_keys "seq 100 | #{FZF} --pointer= --marker= --jump-labels 12345 --bind ctrl-j:jump", :Enter841 tmux.until { |lines| assert_equal 100, lines.match_count }842 tmux.send_keys 'C-j'843 tmux.until { |lines| assert_equal '55', lines[-7] }844 tmux.send_keys 'C-c'845 tmux.until { |lines| assert_equal '5', lines[-7] }846 end847848 def test_pointer849 tmux.send_keys "seq 10 | #{fzf("--pointer '>>'")}", :Enter850 # Assert that specified pointer is displayed851 tmux.until { |lines| assert_equal '>> 1', lines[-3] }
960 unmodified lines