open_buffer(
int read_stdin, // read file from stdin
exarg_T *eap, // for forced 'ff' and 'fenc' or NULL
- int flags) // extra flags for readfile()
+ int flags_arg) // extra flags for readfile()
{
+ int flags = flags_arg;
int retval = OK;
bufref_T old_curbuf;
#ifdef FEAT_SYN_HL
// 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)
#ifdef FEAT_NETBEANS_INTG
&& netbeansReadFile
#endif
* READ_STDIN read from stdin instead of a file
* READ_BUFFER read from curbuf instead of a file (converting after reading
* stdin)
+ * READ_NOFILE do not read a file, only trigger BufReadCmd
* READ_DUMMY read into a dummy buffer (to check if file contents changed)
* READ_KEEP_UNDO don't clear undo info or read it from a file
* READ_FIFO read from fifo/socket instead of a file
#endif
curbuf->b_op_start = orig_start;
+
+ if (flags & READ_NOFILE)
+ return FAIL;
}
if ((shortmess(SHM_OVER) || curbuf->b_help) && p_verbose == 0)
au! BufReadCmd
endfunc
+" BufReadCmd is triggered for a "nofile" buffer
+func Test_BufReadCmdNofile()
+ new somefile
+ set buftype=nofile
+ au BufReadCmd somefile call setline(1, 'triggered')
+ edit
+ call assert_equal('triggered', getline(1))
+
+ au! BufReadCmd
+ bwipe!
+endfunc
+
func Test_augroup_deleted()
" This caused a crash before E936 was introduced
augroup x
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 272,
/**/
271,
/**/
#define READ_KEEP_UNDO 0x20 // keep undo info
#define READ_FIFO 0x40 // read from fifo or socket
#define READ_NOWINENTER 0x80 // do not trigger BufWinEnter
+#define READ_NOFILE 0x100 // do not read a file, do trigger BufReadCmd
// Values for change_indent()
#define INDENT_SET 1 // set indent