Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated for version 7.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)
  • Loading branch information...
commit 3ebfa6942c25bd763589a76ca0bc7916fc8b22f5 1 parent 5ce890a
Bram Moolenaar authored
3  src/ex_cmds.c
@@ -25,7 +25,6 @@ static int viminfo_encoding __ARGS((vir_T *virp));
25 25 static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
26 26 #endif
27 27
28   -static int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
29 28 static int check_readonly __ARGS((int *forceit, buf_T *buf));
30 29 #ifdef FEAT_AUTOCMD
31 30 static void delbuf_msg __ARGS((char_u *name));
@@ -2722,7 +2721,7 @@ do_write(eap)
2722 2721 * May set eap->forceit if a dialog says it's OK to overwrite.
2723 2722 * Return OK if it's OK, FAIL if it is not.
2724 2723 */
2725   - static int
  2724 + int
2726 2725 check_overwrite(eap, buf, fname, ffname, other)
2727 2726 exarg_T *eap;
2728 2727 buf_T *buf;
13 src/ex_cmds2.c
@@ -1489,6 +1489,7 @@ dialog_changed(buf, checkall)
1489 1489 char_u buff[DIALOG_MSG_SIZE];
1490 1490 int ret;
1491 1491 buf_T *buf2;
  1492 + exarg_T ea;
1492 1493
1493 1494 dialog_msg(buff, _("Save changes to \"%s\"?"),
1494 1495 (buf->b_fname != NULL) ?
@@ -1498,13 +1499,19 @@ dialog_changed(buf, checkall)
1498 1499 else
1499 1500 ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
1500 1501
  1502 + /* Init ea pseudo-structure, this is needed for the check_overwrite()
  1503 + * function. */
  1504 + ea.append = ea.forceit = FALSE;
  1505 +
1501 1506 if (ret == VIM_YES)
1502 1507 {
1503 1508 #ifdef FEAT_BROWSE
1504 1509 /* May get file name, when there is none */
1505 1510 browse_save_fname(buf);
1506 1511 #endif
1507   - if (buf->b_fname != NULL) /* didn't hit Cancel */
  1512 + if (buf->b_fname != NULL && check_overwrite(&ea, buf,
  1513 + buf->b_fname, buf->b_ffname, FALSE) == OK)
  1514 + /* didn't hit Cancel */
1508 1515 (void)buf_write_all(buf, FALSE);
1509 1516 }
1510 1517 else if (ret == VIM_NO)
@@ -1532,7 +1539,9 @@ dialog_changed(buf, checkall)
1532 1539 /* May get file name, when there is none */
1533 1540 browse_save_fname(buf2);
1534 1541 #endif
1535   - if (buf2->b_fname != NULL) /* didn't hit Cancel */
  1542 + if (buf2->b_fname != NULL && check_overwrite(&ea, buf2,
  1543 + buf2->b_fname, buf2->b_ffname, FALSE) == OK)
  1544 + /* didn't hit Cancel */
1536 1545 (void)buf_write_all(buf2, FALSE);
1537 1546 #ifdef FEAT_AUTOCMD
1538 1547 /* an autocommand may have deleted the buffer */
1  src/proto/ex_cmds.pro
@@ -23,6 +23,7 @@ void ex_file __ARGS((exarg_T *eap));
23 23 void ex_update __ARGS((exarg_T *eap));
24 24 void ex_write __ARGS((exarg_T *eap));
25 25 int do_write __ARGS((exarg_T *eap));
  26 +int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
26 27 void ex_wnext __ARGS((exarg_T *eap));
27 28 void do_wqall __ARGS((exarg_T *eap));
28 29 int not_writing __ARGS((void));
2  src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
715 715 static int included_patches[] =
716 716 { /* Add new patch number below this line */
717 717 /**/
  718 + 507,
  719 +/**/
718 720 506,
719 721 /**/
720 722 505,

0 comments on commit 3ebfa69

Please sign in to comment.
Something went wrong with that request. Please try again.