Fix toggle-preview-wrap action

Fix #2336
This commit is contained in:
Junegunn Choi 2021-02-01 23:14:21 +09:00
parent 1cfeec0ca3
commit c862af09f2
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 15 additions and 0 deletions

View File

@ -2222,6 +2222,8 @@ func (t *Terminal) Loop() {
case actTogglePreviewWrap:
if t.hasPreviewWindow() {
t.previewOpts.wrap = !t.previewOpts.wrap
// Reset preview version so that full redraw occurs
t.previewed.version = 0
req(reqPreviewRefresh)
}
case actToggleSort:

View File

@ -1864,6 +1864,19 @@ class TestGoFZF < TestBase
tmux.send_keys "#{FZF} --preview 'seq 1000 | nl' --preview-window down:noborder:follow", :Enter
tmux.until { |lines| assert_equal '1000 1000', lines[-1].strip }
end
def test_toggle_preview_wrap
tmux.send_keys "#{FZF} --preview 'for i in $(seq $FZF_PREVIEW_COLUMNS); do echo -n .; done; echo wrapped; echo 2nd line' --bind ctrl-w:toggle-preview-wrap", :Enter
2.times do
tmux.until { |lines| assert_includes lines[2], '2nd line' }
tmux.send_keys 'C-w'
tmux.until do |lines|
assert_includes lines[2], 'wrapped'
assert_includes lines[3], '2nd line'
end
tmux.send_keys 'C-w'
end
end
end
module TestShell