core: quit-after-last-window-closed works properly with "exit"

Fixes #1085

This moves the logic of exiting when there are no surfaces left fully to
apprt and away from the core.
This commit is contained in:
Mitchell Hashimoto
2023-12-13 16:35:14 -08:00
parent cc6270f549
commit b021d76edf
3 changed files with 4 additions and 4 deletions

View File

@ -103,8 +103,8 @@ pub fn tick(self: *App, rt_app: *apprt.App) !bool {
// doesn't want to quit, then we can't force it to.
defer self.quit = false;
// We quit if our quit flag is on or if we have closed all surfaces.
return self.quit or self.surfaces.items.len == 0;
// We quit if our quit flag is on
return self.quit;
}
/// Update the configuration associated with the app. This can only be

View File

@ -111,7 +111,7 @@ pub const App = struct {
// Tick the terminal app
const should_quit = try self.app.tick(self);
if (should_quit) {
if (should_quit or self.app.surfaces.items.len == 0) {
for (self.app.surfaces.items) |surface| {
surface.close(false);
}

View File

@ -316,7 +316,7 @@ pub fn run(self: *App) !void {
// Tick the terminal app
const should_quit = try self.core_app.tick(self);
if (should_quit) self.quit();
if (should_quit or self.core_app.surfaces.items.len == 0) self.quit();
}
}