diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer_defs.h | 3 | ||||
-rw-r--r-- | src/nvim/ex_cmds_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 22 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 2 |
5 files changed, 18 insertions, 15 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index a4d9229b51..2fe85e0543 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -525,7 +525,8 @@ struct file_buffer { int b_flags; // various BF_ flags int b_locked; // Buffer is being closed or referenced, don't // let autocommands wipe it out. - int b_ro_locked; // Replacement for curbuf_lock + int b_ro_locked; // Non-zero when the buffer can't be changed. + // Used for FileChangedRO // // b_ffname has the full path of the file (NULL for no name). diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h index f928c61ea4..d64b14c9c5 100644 --- a/src/nvim/ex_cmds_defs.h +++ b/src/nvim/ex_cmds_defs.h @@ -58,7 +58,7 @@ #define EX_SBOXOK 0x40000 // allowed in the sandbox #define EX_CMDWIN 0x80000 // allowed in cmdline window; when missing // disallows editing another buffer when - // curbuf_lock is set + // current buffer is locked #define EX_MODIFY 0x100000 // forbidden in non-'modifiable' buffer #define EX_FLAGS 0x200000 // allow flags after count in argument #define EX_FILES (EX_XFILE | EX_EXTRA) // multiple extra files allowed diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 27c98a13a6..7c8da4800e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1518,7 +1518,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, goto doend; } - // Disallow editing another buffer when "curbuf_lock" is set. + // Disallow editing another buffer when "curbuf->b_ro_locked" is set. // Do allow ":checktime" (it is postponed). // Do allow ":edit" (check for an argument later). // Do allow ":file" with no arguments (check for an argument later). @@ -1601,7 +1601,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, else ea.arg = skipwhite(p); - // ":file" cannot be run with an argument when "curbuf_lock" is set + // ":file" cannot be run with an argument when "curbuf->b_ro_locked" is set if (ea.cmdidx == CMD_file && *ea.arg != NUL && curbuf_locked()) { goto doend; } @@ -7344,16 +7344,18 @@ do_exedit( old_curwin == NULL ? curwin : NULL); } else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit) || *eap->arg != NUL) { - /* Can't edit another file when "curbuf_lock" is set. Only ":edit" - * can bring us here, others are stopped earlier. */ - if (*eap->arg != NUL && curbuf_locked()) + // Can't edit another file when "curbuf->b_ro_lockec" is set. Only ":edit" + // can bring us here, others are stopped earlier. + if (*eap->arg != NUL && curbuf_locked()) { return; + } n = readonlymode; - if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) - readonlymode = TRUE; - else if (eap->cmdidx == CMD_enew) - readonlymode = FALSE; /* 'readonly' doesn't make sense in an - empty buffer */ + if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview) { + readonlymode = true; + } else if (eap->cmdidx == CMD_enew) { + readonlymode = false; // 'readonly' doesn't make sense + // in an empty buffer + } if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd) { setpcmark(); } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 2dfe2950fc..4ebd384ae0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2412,8 +2412,8 @@ char_u * get_text_locked_msg(void) { } } -/// Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is -/// and give an error message. +/// Check if "curbuf->b_ro_locked" or "allbuf_lock" is set and +/// return TRUE when it is and give an error message. int curbuf_locked(void) { if (curbuf->b_ro_locked > 0) { diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 6bd64caa6c..c0b9dd7696 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -2965,7 +2965,7 @@ func Test_cclose_in_autocmd() " call test_override('starting', 0) endfunc -" Check that ":file" without an argument is possible even when "curbuf_lock" +" Check that ":file" without an argument is possible even when curbuf is locked " is set. func Test_file_from_copen() " Works without argument. |