From 274b13df9e4cd75ac81f7f3749ac192667c448e3 Mon Sep 17 00:00:00 2001 From: valoq Date: Mon, 7 Sep 2026 21:50:31 +0200 Subject: [PATCH] Fix: Main loop blocked by double quit (#2674) --- app.go | 8 ++++++++ eval.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app.go b/app.go index 4bd9b3ed..562d32af 100644 --- a/app.go +++ b/app.go @@ -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) diff --git a/eval.go b/eval.go index d3990cc3..59b16796 100644 --- a/eval.go +++ b/eval.go @@ -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 }