Skip to content

Commit

Permalink
Kill preview process when hiding the preview window
Browse files Browse the repository at this point in the history
via toggle-preview, hide-preview, or change-preview-window
  • Loading branch information
junegunn committed Mar 8, 2024
1 parent eec557b commit fa0aa55
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3382,6 +3382,9 @@ func (t *Terminal) Loop() {
// Discard the preview content so that it won't accidentally appear
// when preview window is re-enabled and previewDelay is triggered
t.previewer.lines = nil

// Also kill the preview process if it's still running
t.cancelPreview()
}
}
case actTogglePreviewWrap:
Expand Down Expand Up @@ -3988,11 +3991,18 @@ func (t *Terminal) Loop() {

// Full redraw
if !currentPreviewOpts.sameLayout(t.previewOpts) {
wasHidden := t.pwindow == nil
// Preview command can be running in the background if the size of
// the preview window is 0 but not 'hidden'
wasHidden := currentPreviewOpts.hidden
updatePreviewWindow(false)
if wasHidden && t.hasPreviewWindow() {
// Restart
refreshPreview(t.previewOpts.command)
} else if t.previewOpts.hidden {
// Cancel
t.cancelPreview()
} else {
// Refresh
req(reqPreviewRefresh)
}
} else if !currentPreviewOpts.sameContentLayout(t.previewOpts) {
Expand Down

0 comments on commit fa0aa55

Please sign in to comment.