vim-patch:9.0.0274: netrw plugin does not show remote files

Problem:    Netrw plugin does not show remote files.
Solution:   Do read a file when 'buftype' is "acwrite". (closes vim/vim#10983)
c312619f7c
This commit is contained in:
zeertzjq 2022-08-26 20:03:08 +08:00
parent 900a151bf5
commit 52f00a6c4d
2 changed files with 33 additions and 14 deletions

View File

@ -227,7 +227,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags_arg)
// A buffer without an actual file should not use the buffer name to read a
// file.
if (bt_quickfix(curbuf) || bt_nofilename(curbuf)) {
if (bt_nofileread(curbuf)) {
flags |= READ_NOFILE;
}
@ -812,6 +812,18 @@ static void free_buffer(buf_T *buf)
}
}
/// Free the b_wininfo list for buffer "buf".
static void clear_wininfo(buf_T *buf)
{
wininfo_T *wip;
while (buf->b_wininfo != NULL) {
wip = buf->b_wininfo;
buf->b_wininfo = wip->wi_next;
free_wininfo(wip, buf);
}
}
/// Free stuff in the buffer for ":bdel" and when wiping out the buffer.
///
/// @param buf Buffer pointer
@ -846,18 +858,6 @@ static void free_buffer_stuff(buf_T *buf, int free_flags)
buf_updates_unload(buf, false);
}
/// Free the b_wininfo list for buffer "buf".
static void clear_wininfo(buf_T *buf)
{
wininfo_T *wip;
while (buf->b_wininfo != NULL) {
wip = buf->b_wininfo;
buf->b_wininfo = wip->wi_next;
free_wininfo(wip, buf);
}
}
/// Go to another buffer. Handles the result of the ATTENTION dialog.
void goto_buffer(exarg_T *eap, int start, int dir, int count)
{
@ -3834,7 +3834,8 @@ bool bt_terminal(const buf_T *const buf)
}
/// @return true if "buf" is a "nofile", "acwrite", "terminal" or "prompt"
/// buffer. This means the buffer name is not a file name.
/// buffer. This means the buffer name may not be a file name,
/// at least not for writing the buffer.
bool bt_nofilename(const buf_T *const buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
@ -3844,6 +3845,17 @@ bool bt_nofilename(const buf_T *const buf)
|| buf->b_p_bt[0] == 'p');
}
/// @return true if "buf" is a "nofile", "quickfix", "terminal" or "prompt"
/// buffer. This means the buffer is not to be read from a file.
static bool bt_nofileread(const buf_T *const buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
|| buf->b_p_bt[0] == 't'
|| buf->b_p_bt[0] == 'q'
|| buf->b_p_bt[0] == 'p');
}
/// @return true if "buf" has 'buftype' set to "nofile".
bool bt_nofile(const buf_T *const buf)
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT

View File

@ -1887,6 +1887,13 @@ func Test_bufadd_bufload()
call bufload(buf)
call assert_equal([''], getbufline(buf, 1, '$'))
" when 'buftype' is "acwrite" then bufload() DOES read the file
bwipe! XotherName
let buf = bufadd('XotherName')
call setbufvar(buf, '&bt', 'acwrite')
call bufload(buf)
call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
bwipe someName
bwipe XotherName
call assert_equal(0, bufexists('someName'))