Skip to content

Commit 42c16f1

Browse files
authored
Clean image preview on set preview! (#1350)
Properly clean (`ueberzug`) image preview when disabling it using for example `set preview!`. Also change "clearing" to "cleaning" in docs.
1 parent 23418ad commit 42c16f1

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ Set the path of a cleaner file.
674674
The file should be executable.
675675
This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled.
676676
Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
677-
Preview clearing is disabled when the value of this option is left empty.
677+
Preview cleaning is disabled when the value of this option is left empty.
678678
679679
cursoractivefmt string (default "\033[7m")
680680
cursorparentfmt string (default "\033[7m")

docstring.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eval.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,12 +611,14 @@ func (e *setExpr) eval(app *app, args []string) {
611611
app.ui.echoerr("preview: value should be empty, 'true', or 'false'")
612612
return
613613
}
614+
app.ui.loadFile(app, true)
614615
case "nopreview":
615616
if e.val != "" {
616617
app.ui.echoerrf("nopreview: unexpected value: %s", e.val)
617618
return
618619
}
619620
gOpts.preview = false
621+
app.ui.loadFile(app, true)
620622
case "preview!":
621623
if e.val != "" {
622624
app.ui.echoerrf("preview!: unexpected value: %s", e.val)
@@ -627,6 +629,7 @@ func (e *setExpr) eval(app *app, args []string) {
627629
return
628630
}
629631
gOpts.preview = !gOpts.preview
632+
app.ui.loadFile(app, true)
630633
case "previewer":
631634
gOpts.previewer = replaceTilde(e.val)
632635
case "promptfmt":

lf.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ Format string of the box drawing characters enabled by the `drawbox` option.
825825
cleaner string (default '') (not called if empty)
826826
.EE
827827
.PP
828-
Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled. Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. Preview clearing is disabled when the value of this option is left empty.
828+
Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled. Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. Preview cleaning is disabled when the value of this option is left empty.
829829
.PP
830830
.EX
831831
cursoractivefmt string (default "\e033[7m")

ui.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,14 @@ func (ui *ui) loadFile(app *app, volatile bool) {
696696
onSelect(app)
697697
}
698698

699-
if !gOpts.preview {
700-
return
701-
}
702-
703699
if volatile {
704700
app.nav.previewChan <- ""
705701
}
706702

703+
if !gOpts.preview {
704+
return
705+
}
706+
707707
if curr.IsDir() {
708708
ui.dirPrev = app.nav.loadDir(curr.path)
709709
} else if curr.Mode().IsRegular() {

0 commit comments

Comments
 (0)