Skip to content

Commit 3ebfa69

Browse files
committed
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)
1 parent 5ce890a commit 3ebfa69

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/ex_cmds.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ static int viminfo_encoding __ARGS((vir_T *virp));
2525
static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
2626
#endif
2727

28-
static int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
2928
static int check_readonly __ARGS((int *forceit, buf_T *buf));
3029
#ifdef FEAT_AUTOCMD
3130
static void delbuf_msg __ARGS((char_u *name));
@@ -2722,7 +2721,7 @@ do_write(eap)
27222721
* May set eap->forceit if a dialog says it's OK to overwrite.
27232722
* Return OK if it's OK, FAIL if it is not.
27242723
*/
2725-
static int
2724+
int
27262725
check_overwrite(eap, buf, fname, ffname, other)
27272726
exarg_T *eap;
27282727
buf_T *buf;

src/ex_cmds2.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,7 @@ dialog_changed(buf, checkall)
14891489
char_u buff[DIALOG_MSG_SIZE];
14901490
int ret;
14911491
buf_T *buf2;
1492+
exarg_T ea;
14921493

14931494
dialog_msg(buff, _("Save changes to \"%s\"?"),
14941495
(buf->b_fname != NULL) ?
@@ -1498,13 +1499,19 @@ dialog_changed(buf, checkall)
14981499
else
14991500
ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1);
15001501

1502+
/* Init ea pseudo-structure, this is needed for the check_overwrite()
1503+
* function. */
1504+
ea.append = ea.forceit = FALSE;
1505+
15011506
if (ret == VIM_YES)
15021507
{
15031508
#ifdef FEAT_BROWSE
15041509
/* May get file name, when there is none */
15051510
browse_save_fname(buf);
15061511
#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 */
15081515
(void)buf_write_all(buf, FALSE);
15091516
}
15101517
else if (ret == VIM_NO)
@@ -1532,7 +1539,9 @@ dialog_changed(buf, checkall)
15321539
/* May get file name, when there is none */
15331540
browse_save_fname(buf2);
15341541
#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 */
15361545
(void)buf_write_all(buf2, FALSE);
15371546
#ifdef FEAT_AUTOCMD
15381547
/* an autocommand may have deleted the buffer */

src/proto/ex_cmds.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void ex_file __ARGS((exarg_T *eap));
2323
void ex_update __ARGS((exarg_T *eap));
2424
void ex_write __ARGS((exarg_T *eap));
2525
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));
2627
void ex_wnext __ARGS((exarg_T *eap));
2728
void do_wqall __ARGS((exarg_T *eap));
2829
int not_writing __ARGS((void));

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
507,
717719
/**/
718720
506,
719721
/**/

0 commit comments

Comments
 (0)