diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-26 19:04:20 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-27 06:12:52 +0800 |
commit | 900a151bf541c7fa77a56b4881c4836a1cabcde6 (patch) | |
tree | 32973768295e652ac35bdc946a7f76d5cefcc0d0 /src/nvim/buffer.c | |
parent | b0e052a8b30ce84221c3f992e111713451633b36 (diff) | |
download | rneovim-900a151bf541c7fa77a56b4881c4836a1cabcde6.tar.gz rneovim-900a151bf541c7fa77a56b4881c4836a1cabcde6.tar.bz2 rneovim-900a151bf541c7fa77a56b4881c4836a1cabcde6.zip |
vim-patch:9.0.0272: BufReadCmd not triggered when loading a "nofile" buffer
Problem: BufReadCmd not triggered when loading a "nofile" buffer. (Maxim
Kim)
Solution: Call readfile() but bail out before reading a file.
(closes vim/vim#10983)
https://github.com/vim/vim/commit/b1d2c8116cb5577961ea109651fb888b5e58265f
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r-- | src/nvim/buffer.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 24fd1b3022..3211b83dc7 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -165,11 +165,12 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags) /// /// @param read_stdin read file from stdin /// @param eap for forced 'ff' and 'fenc' or NULL -/// @param flags extra flags for readfile() +/// @param flags_arg extra flags for readfile() /// /// @return FAIL for failure, OK otherwise. -int open_buffer(int read_stdin, exarg_T *eap, int flags) +int open_buffer(int read_stdin, exarg_T *eap, int flags_arg) { + int flags = flags_arg; int retval = OK; bufref_T old_curbuf; long old_tw = curbuf->b_p_tw; @@ -224,8 +225,14 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags) // mark cursor position as being invalid curwin->w_valid = 0; + // A buffer without an actual file should not use the buffer name to read a + // file. + if (bt_quickfix(curbuf) || bt_nofilename(curbuf)) { + flags |= READ_NOFILE; + } + // Read the file if there is one. - if (curbuf->b_ffname != NULL && !bt_quickfix(curbuf) && !bt_nofilename(curbuf)) { + if (curbuf->b_ffname != NULL) { #ifdef UNIX int save_bin = curbuf->b_p_bin; int perm; |