Kill preview process when hiding the preview window

via toggle-preview, hide-preview, or change-preview-window
This commit is contained in:
Junegunn Choi 2024-03-08 22:01:45 +09:00
parent eec557b6aa
commit fa0aa5510d
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
1 changed files with 11 additions and 1 deletions

View File

@ -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:
@ -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) {