diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-07-09 10:15:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-09 10:15:18 +0200 |
commit | 1c416892879de6b78038f2cc2f1487eff46abb60 (patch) | |
tree | 3895521bc907b7a0617940c21272ac7ee9f052da /src/nvim/ex_docmd.c | |
parent | 27118c6eb3351b0df96e2514e8f3806108e50cf7 (diff) | |
parent | 9c93e6461c8c6ec2e8d3e73f506389ac7086d531 (diff) | |
download | rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.tar.gz rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.tar.bz2 rneovim-1c416892879de6b78038f2cc2f1487eff46abb60.zip |
Merge pull request #12971 from vigoux/decurbuf
Decrease reliance on curbuf in BUFEMPTY and `undo.c`
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a50c5527ca..bec96bea15 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; } @@ -7345,16 +7345,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(); } |