Guarantee preview/previewClear ordering (#537)

* Use chan struct{} in place of chan bool

* Revert "nav.checkReg now returns a boolean instead of calling nav.preview"

* Guarantee preview/previewClear ordering

* Pass the file path to the cleaner script
This commit is contained in:
neeshy authored and GitHub committed 2020-12-27 04:23:03 +03:00
1 parent 72567c9237
commit 1e94f4533e
9 files changed
+48 -41

No files matched your search

+5 -8
View File
@@ -25,7 +25,7 @@ type app struct {
ui *ui
nav *nav
ticker *time.Ticker
quitChan chan bool
quitChan chan struct{}
cmd *exec.Cmd
cmdIn io.WriteCloser
cmdOutBuf []byte
@@ -38,7 +38,7 @@ func newApp(screen tcell.Screen) *app {
ui := newUI(screen)
nav := newNav(ui.wins[0].h)
quitChan := make(chan bool, 1)
quitChan := make(chan struct{}, 1)
app := &app{
ui: ui,
@@ -213,7 +213,7 @@ func (app *app) loop() {
continue
}
go app.nav.previewClear()
app.nav.previewChan <- ""
log.Print("bye!")
@@ -312,10 +312,7 @@ func (app *app) loop() {
app.ui.draw(app.nav)
case r := <-app.nav.regChan:
if app.nav.checkReg(r) {
win := app.ui.wins[len(app.ui.wins)-1]
go app.nav.preview(r.path, win)
}
app.nav.checkReg(r)
app.nav.regCache[r.path] = r
@@ -407,7 +404,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
go app.nav.previewClear()
app.nav.previewChan <- ""
app.ui.pause()
defer app.ui.resume()
defer app.nav.renew()