]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.2.0443: GUI: cancelling save dialog overwrites or discards unnamed buffer v9.2.0443
authorHirohito Higashi <h.east.727@gmail.com>
Tue, 5 May 2026 19:02:59 +0000 (19:02 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 5 May 2026 19:02:59 +0000 (19:02 +0000)
commitcf947e7ef09fc8a63f447b54b107585b8f3b7abe
treec7c0646402f35bf3dab8ceacfaab017e43cbe4ec
parent2bfddbea47e1afa79ecd094040418abdba88bc83
patch 9.2.0443: GUI: cancelling save dialog overwrites or discards unnamed buffer

Problem:  When closing gvim with an unsaved unnamed buffer, choosing
          "Yes" in the "Save changes?" dialog and then "Cancel" in the
          file selection dialog either silently writes the buffer to a
          file named "Untitled" (overwriting any existing file with
          that name) or discards the buffer altogether
          (vibs29, after v9.1.0265).
Solution: In dialog_changed(), if browse_save_fname() leaves the buffer
          without a file name, treat it as a cancel and return without
          saving.  Also stop clearing the modified flag in the restore
          path on write failure, so the unsaved changes are kept and
          the caller (e.g. gui_shell_closed()) can also cancel the
          close.  Pre-fill the file dialog with "Untitled" to match
          the preceding "Save changes to ..." prompt.  Add a test for
          the write-failure path (Hirohito Higashi).

fixes:  #20132
closes: #20143

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_cmds2.c
src/testdir/test_buffer.vim
src/version.c