mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
patch 9.1.0208: winfixbuf does not allow to re-edit current buffer
Problem: winfixbuf does not allow to re-edit current buffer (Tim Pope, after v9.1.0147) Solution: Explicitly allow :e even when 'winfixbuf' is set, since it just re-loads the current buffer (Colin Kennedy) fixes: #14237 closes: #14286 Signed-off-by: Colin Kennedy <colinvfx@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
e5f2280381
commit
65e580bd56
@ -460,6 +460,40 @@ restore_dbg_stuff(struct dbg_stuff *dsp)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check if ffname differs from fnum.
|
||||
* fnum is a buffer number. 0 == current buffer, 1-or-more must be a valid buffer ID.
|
||||
* ffname is a full path to where a buffer lives on-disk or would live on-disk.
|
||||
*
|
||||
*/
|
||||
static int
|
||||
is_other_file(int fnum, char_u *ffname)
|
||||
{
|
||||
if (fnum != 0)
|
||||
{
|
||||
if (fnum == curbuf->b_fnum)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (ffname == NULL)
|
||||
return TRUE;
|
||||
|
||||
if (*ffname == NUL)
|
||||
return FALSE;
|
||||
|
||||
// TODO: Need a reliable way to know whether a buffer is meant to live on-disk
|
||||
// !curbuf->b_dev_valid is not always available (example: missing on Windows)
|
||||
if (curbuf->b_sfname != NULL
|
||||
&& *curbuf->b_sfname != NUL)
|
||||
// This occurs with unsaved buffers. In which case `ffname`
|
||||
// actually corresponds to curbuf->b_sfname
|
||||
return fnamecmp(ffname, curbuf->b_sfname) != 0;
|
||||
|
||||
return otherfile(ffname);
|
||||
}
|
||||
|
||||
/*
|
||||
* do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi"
|
||||
* command is given.
|
||||
@ -7256,12 +7290,15 @@ ex_open(exarg_T *eap)
|
||||
static void
|
||||
ex_edit(exarg_T *eap)
|
||||
{
|
||||
char_u *ffname = eap->cmdidx == CMD_enew ? NULL : eap->arg;
|
||||
|
||||
// Exclude commands which keep the window's current buffer
|
||||
if (
|
||||
eap->cmdidx != CMD_badd
|
||||
&& eap->cmdidx != CMD_balt
|
||||
// All other commands must obey 'winfixbuf' / ! rules
|
||||
&& !check_can_set_curbuf_forceit(eap->forceit))
|
||||
&& (is_other_file(0, ffname) && !check_can_set_curbuf_forceit(eap->forceit))
|
||||
)
|
||||
return;
|
||||
|
||||
do_exedit(eap, NULL);
|
||||
|
Reference in New Issue
Block a user