8000 Exhaust queued entries in previewChan prior to calling preview script by neeshy · Pull Request #562 · gokcehan/lf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Exhaust queued entries in previewChan prior to calling preview script #562

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

Merged
merged 2 commits into from
Jan 19, 2021
Merged
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
34 changes: 23 additions & 11 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,23 +460,35 @@ func (nav *nav) position() {
}

func (nav *nav) previewLoop(ui *ui) {
var path string
for {
p, ok := <-nav.previewChan
if !ok {
return
var prev string
for path := range nav.previewChan {
var clear bool
if len(path) == 0 {
clear = true
}
if len(p) != 0 {
win := ui.wins[len(ui.wins)-1]
nav.preview(p, win)
path = p
} else if len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview {
cmd := exec.Command(gOpts.cleaner, path)
loop:
for {
select {
case path = <-nav.previewChan:
if len(path) == 0 {
clear = true
}
default:
break loop
}
}
if clear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview {
cmd := exec.Command(gOpts.cleaner, prev)
if err := cmd.Run(); err != nil {
log.Printf("cleaning preview: %s", err)
}
nav.volatilePreview = false
}
if len(path) != 0 {
win := ui.wins[len(ui.wins)-1]
nav.preview(path, win)
prev = path
}
}
}

Expand Down
0