summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2012-04-25 17:32:18 +0200
committerBram Moolenaar <bram@vim.org>2012-04-25 17:32:18 +0200
commit7fa45d28dd027d76e6339ad356c0e9988427bf47 (patch)
tree4b231ec757242dcde0b2720e65f9e4d7d2475256
parent7d465d7711eb3d1f3ec90c1d662cbfcb92626587 (diff)
downloadvim-7fa45d28dd027d76e6339ad356c0e9988427bf47.tar.gz
updated for version 7.3.507v7.3.507v7-3-507
Problem: 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) Solution: Call check_overwrite() before writing. (Christian Brabandt)
-rw-r--r--src/ex_cmds.c3
-rw-r--r--src/ex_cmds2.c13
-rw-r--r--src/proto/ex_cmds.pro1
-rw-r--r--src/version.c2
4 files changed, 15 insertions, 4 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 005f28f7..d719826b 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -25,7 +25,6 @@ static int viminfo_encoding __ARGS((vir_T *virp));
static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
#endif
-static int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
static int check_readonly __ARGS((int *forceit, buf_T *buf));
#ifdef FEAT_AUTOCMD
static void delbuf_msg __ARGS((char_u *name));
@@ -2722,7 +2721,7 @@ theend:
* May set eap->forceit if a dialog says it's OK to overwrite.
* Return OK if it's OK, FAIL if it is not.
*/
- static int
+ int
check_overwrite(eap, buf, fname, ffname, other)
exarg_T *eap;
buf_T *buf;
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 2bce6dfd..611a3633 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1489,6 +1489,7 @@ dialog_changed(buf, checkall)
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,19 @@ dialog_changed(buf, checkall)
else
ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
+ /* Init ea pseudo-structure, this is needed for the check_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 && check_overwrite(&ea, buf,
+ buf->b_fname, buf->b_ffname, FALSE) == OK)
+ /* didn't hit Cancel */
(void)buf_write_all(buf, FALSE);
}
else if (ret == VIM_NO)
@@ -1532,7 +1539,9 @@ dialog_changed(buf, checkall)
/* 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 && check_overwrite(&ea, buf2,
+ buf2->b_fname, buf2->b_ffname, FALSE) == 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
index ff868cae..1669d791 100644
--- a/src/proto/ex_cmds.pro
+++ b/src/proto/ex_cmds.pro
@@ -23,6 +23,7 @@ void ex_file __ARGS((exarg_T *eap));
void ex_update __ARGS((exarg_T *eap));
void ex_write __ARGS((exarg_T *eap));
int do_write __ARGS((exarg_T *eap));
+int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
void ex_wnext __ARGS((exarg_T *eap));
void do_wqall __ARGS((exarg_T *eap));
int not_writing __ARGS((void));
diff --git a/src/version.c b/src/version.c
index 9f36e4cc..f4ef8252 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 507,
+/**/
506,
/**/
505,