Fix: Main loop blocked by double quit (#2674)

This commit is contained in:
valoq authored and GitHub committed 2026-09-07 19:50:31 +00:00
1 parent 1c9029e9ec
commit 274b13df9e
2 files changed
+10 -2

No files matched your search

+8
View File
@@ -95,6 +95,14 @@ func (app *app) quit() {
}
}
// requestQuit signals the main loop to quit and never blocks when a request is already pending.
func (app *app) requestQuit() {
select {
case app.quitChan <- struct{}{}:
default:
}
}
func (app *app) readFile(path string) {
log.Printf("reading file: %s", path)
+2 -2
View File
@@ -1046,7 +1046,7 @@ func (e *callExpr) eval(app *app, _ []string) {
switch e.name {
case "quit":
app.quitChan <- struct{}{}
app.requestQuit()
case "up":
if app.nav.up(e.count) {
app.ui.loadFile(app, true)
@@ -1111,7 +1111,7 @@ func (e *callExpr) eval(app *app, _ []string) {
} else {
if gSelectionPath != "" || gPrintSelection {
app.selectionOut, _ = app.nav.currFileOrSelections()
app.quitChan <- struct{}{}
app.requestQuit()
return
}