Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean image preview on set preview! #1350

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ 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.
Preview cleaning is disabled when the value of this option is left empty.

cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
Expand Down
2 changes: 1 addition & 1 deletion docstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,14 @@ func (e *setExpr) eval(app *app, args []string) {
app.ui.echoerr("preview: value should be empty, 'true', or 'false'")
return
}
app.ui.loadFile(app, true)
case "nopreview":
if e.val != "" {
app.ui.echoerrf("nopreview: unexpected value: %s", e.val)
return
}
gOpts.preview = false
app.ui.loadFile(app, true)
case "preview!":
if e.val != "" {
app.ui.echoerrf("preview!: unexpected value: %s", e.val)
Expand All @@ -627,6 +629,7 @@ func (e *setExpr) eval(app *app, args []string) {
return
}
gOpts.preview = !gOpts.preview
app.ui.loadFile(app, true)
case "previewer":
gOpts.previewer = replaceTilde(e.val)
case "promptfmt":
Expand Down
2 changes: 1 addition & 1 deletion lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ Format string of the box drawing characters enabled by the `drawbox` option.
cleaner string (default '') (not called if empty)
.EE
.PP
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.
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.
.PP
.EX
cursoractivefmt string (default "\e033[7m")
Expand Down
8 changes: 4 additions & 4 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,14 @@ func (ui *ui) loadFile(app *app, volatile bool) {
onSelect(app)
}

if !gOpts.preview {
return
}

if volatile {
app.nav.previewChan <- ""
}

if !gOpts.preview {
return
}

if curr.IsDir() {
ui.dirPrev = app.nav.loadDir(curr.path)
} else if curr.Mode().IsRegular() {
Expand Down