From ab1a65b998b62735a502e9d8fa69d57fd4bfc085 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 06:05:07 +0000 Subject: [PATCH 1/3] Initial plan From ee608983ddee8a179089ae2cd3df39ff51a0a0e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 06:10:18 +0000 Subject: [PATCH 2/3] Implement confirm on close for unsaved buffers - Modify close_request to send :q command to neovim instead of closing immediately - Let neovim handle unsaved changes confirmation with its standard behavior - Preserve existing vimleavepre -> io_loop -> close() flow for clean exit - Prevent accidental data loss from Alt+F4 or window close button Co-authored-by: vhakulinen <4594126+vhakulinen@users.noreply.github.com> --- ui/src/components/appwindow/imp.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ui/src/components/appwindow/imp.rs b/ui/src/components/appwindow/imp.rs index ef71b59..0a5fe6f 100644 --- a/ui/src/components/appwindow/imp.rs +++ b/ui/src/components/appwindow/imp.rs @@ -791,7 +791,25 @@ impl WindowImpl for AppWindow { warn!("failed to save window state: {}", err); } - self.parent_close_request() + // Instead of closing immediately, send :q to neovim to let it handle + // unsaved changes confirmation. If neovim exits cleanly, the window + // will be closed through the existing vimleavepre -> io_loop flow. + spawn_local!(glib::clone!( + #[weak(rename_to = nvim)] + self.nvim, + async move { + nvim.nvim_command("q") + .await + .unwrap_or_else(|err| { + // If the command fails (e.g., due to unsaved changes), + // neovim will display its standard error message + debug!("nvim_command 'q' failed: {}", err); + }); + } + )); + + // Prevent the window from closing immediately - let neovim handle it + glib::Propagation::Stop } } From 4db77c9bd59bcfca07dea66f1c66ddef18aec487 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 06:11:40 +0000 Subject: [PATCH 3/3] Clean up test documentation Co-authored-by: vhakulinen <4594126+vhakulinen@users.noreply.github.com> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 04b4dd6..b09b049 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ # Default flatpak-builder build directory. .flatpak-builder +test_confirm_close.md