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 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 } }