diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 02:10:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 02:10:58 +0000 |
commit | bee19c22d569e54513a9c591441c7f411811dc81 (patch) | |
tree | b990d2df9fddb8194bfe49e9205005a0d952bc1f /src/ex_cmds2.c | |
parent | Adding upstream version 2:9.1.0199. (diff) | |
download | vim-bee19c22d569e54513a9c591441c7f411811dc81.tar.xz vim-bee19c22d569e54513a9c591441c7f411811dc81.zip |
Adding upstream version 2:9.1.0374.upstream/2%9.1.0374
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r-- | src/ex_cmds2.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 4a6f519..ce30b8d 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -163,7 +163,7 @@ dialog_changed( char_u buff[DIALOG_MSG_SIZE]; int ret; buf_T *buf2; - exarg_T ea; + exarg_T ea; dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname); if (checkall) @@ -177,14 +177,31 @@ dialog_changed( if (ret == VIM_YES) { + int empty_bufname; + #ifdef FEAT_BROWSE // May get file name, when there is none browse_save_fname(buf); #endif - if (buf->b_fname != NULL && check_overwrite(&ea, buf, - buf->b_fname, buf->b_ffname, FALSE) == OK) + empty_bufname = buf->b_fname == NULL ? TRUE : FALSE; + if (empty_bufname) + buf_set_name(buf->b_fnum, (char_u *)"Untitled"); + + if (check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, FALSE) == OK) + { // didn't hit Cancel - (void)buf_write_all(buf, FALSE); + if (buf_write_all(buf, FALSE) == OK) + return; + } + + // restore to empty when write failed + if (empty_bufname) + { + VIM_CLEAR(buf->b_fname); + VIM_CLEAR(buf->b_ffname); + VIM_CLEAR(buf->b_sfname); + unchanged(buf, TRUE, FALSE); + } } else if (ret == VIM_NO) { |