diff options
author | Colin Kennedy <colinvfx@gmail.com> | 2024-03-26 18:29:30 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-03-26 18:29:30 +0100 |
commit | 65e580bd5610465bb6b9c1a546b7a8d00c76aa47 (patch) | |
tree | 0439fcdce82586b2e608dcfb55de4f34114f6cc8 /src/ex_docmd.c | |
parent | e5f2280381250801a28dcff9823e6f94e7b163fc (diff) |
patch 9.1.0208: winfixbuf does not allow to re-edit current bufferv9.1.0208
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>
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 21ba0d5bc3..981d270dc7 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -461,6 +461,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); |