Bram,
this patch fixes this issue from the todo list:
,----
| When exiting with unsaved changes, selecting an existing file in the file
| dialog, there is no dialog to ask whether the existing file should be
| overwritten. (Felipe G. Nievinski, 2011 Dec 22)
`----
Attached Patch fixes this issue.
regards,
Christian
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2716,6 +2716,15 @@
return retval;
}
+ int
+overwrite(eap, buf, fname)
+ exarg_T *eap;
+ buf_T *buf;
+ char_u *fname; /* file name to be used */
+{
+ return check_overwrite(eap, buf, fname, fname, FALSE);
+}
+
/*
* Check if it is allowed to overwrite a file. If b_flags has BF_NOTEDITED,
* BF_NEW or BF_READERR, check for overwriting current file.
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1489,6 +1489,7 @@
char_u buff[DIALOG_MSG_SIZE];
int ret;
buf_T *buf2;
+ exarg_T ea;
dialog_msg(buff, _("Save changes to \"%s\"?"),
(buf->b_fname != NULL) ?
@@ -1498,13 +1499,16 @@
else
ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
+ /* init ea pseudo-structure, this is needed for overwrite() function */
+ ea.append = ea.forceit = FALSE;
if (ret == VIM_YES)
{
#ifdef FEAT_BROWSE
/* May get file name, when there is none */
browse_save_fname(buf);
#endif
- if (buf->b_fname != NULL) /* didn't hit Cancel */
+ if (buf->b_fname != NULL && overwrite(&ea, buf, buf->b_fname) == OK)
+ /* didn't hit Cancel */
(void)buf_write_all(buf, FALSE);
}
else if (ret == VIM_NO)
@@ -1532,7 +1536,8 @@
/* May get file name, when there is none */
browse_save_fname(buf2);
#endif
- if (buf2->b_fname != NULL) /* didn't hit Cancel */
+ if (buf2->b_fname != NULL && overwrite(&ea, buf2, buf2->b_fname) == OK)
+ /* didn't hit Cancel */
(void)buf_write_all(buf2, FALSE);
#ifdef FEAT_AUTOCMD
/* an autocommand may have deleted the buffer */
diff --git a/src/proto/ex_cmds.pro b/src/proto/ex_cmds.pro
--- a/src/proto/ex_cmds.pro
+++ b/src/proto/ex_cmds.pro
@@ -59,4 +59,5 @@
char_u *get_sign_name __ARGS((expand_T *xp, int idx));
void set_context_in_sign_cmd __ARGS((expand_T *xp, char_u *arg));
void ex_drop __ARGS((exarg_T *eap));
+int overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname));
/* vim: set ft=c : */