Skip to content

Add confirmation dialog when closing window with unsaved buffers#225

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-d5d63a1b-ff98-48bb-9a3a-e5608adca313
Draft

Add confirmation dialog when closing window with unsaved buffers#225
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-d5d63a1b-ff98-48bb-9a3a-e5608adca313

Conversation

Copy link

Copilot AI commented Aug 20, 2025

Fixes #147

When the user tries to close the gnvim window (via Alt+F4, clicking the X button, etc.), gnvim now sends a :q command to neovim instead of closing immediately. This allows neovim to handle unsaved changes with its standard confirmation behavior, preventing accidental data loss.

Changes

  • Modified WindowImpl::close_request() in ui/src/components/appwindow/imp.rs
  • Instead of calling self.parent_close_request(), the implementation now:
    1. Sends :q command to neovim via nvim_command("q")
    2. Returns glib::Propagation::Stop to prevent immediate window closure
    3. Lets the existing vimleavepre → io_loop → close() flow handle clean exit

Behavior

With unsaved changes:

  • User tries to close window
  • Neovim displays "No write since last change (add ! to override)" message
  • Window remains open, allowing user to save (:w) or force quit (:q!)

Without unsaved changes:

  • User tries to close window
  • Neovim exits cleanly
  • Window closes normally through existing exit flow

This approach leverages neovim's built-in quit confirmation logic rather than duplicating it in the GUI layer, ensuring consistent behavior with terminal neovim and maintaining the existing clean exit infrastructure.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits August 20, 2025 06:10
- 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>
Co-authored-by: vhakulinen <4594126+vhakulinen@users.noreply.github.com>
Copilot AI changed the title [WIP] @vhakulinen/gnvim/issues/147 Create PR that implements the requrested feature. Add confirmation dialog when closing window with unsaved buffers Aug 20, 2025
Copilot AI requested a review from vhakulinen August 20, 2025 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confirm on close?

2 participants