diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-07-07 07:21:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 07:21:50 +0800 |
commit | 5e84db5c90db60f68fe69b3585ba742d1a872b90 (patch) | |
tree | ce06952a02c3768eba6180dc24d77421176d62ff /src/nvim/normal.c | |
parent | 4ffe5d018919d3fbea21e667f09f14b9751f9cd5 (diff) | |
parent | d4db87f4932a3a994cd5364c1cf85f0913a37070 (diff) | |
download | rneovim-5e84db5c90db60f68fe69b3585ba742d1a872b90.tar.gz rneovim-5e84db5c90db60f68fe69b3585ba742d1a872b90.tar.bz2 rneovim-5e84db5c90db60f68fe69b3585ba742d1a872b90.zip |
Merge pull request #19261 from zeertzjq/vim-8.2.5023
vim-patch:8.2.{5023,5043,5044}: substitute textlock fixes
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3a552ef053..9696130070 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -432,6 +432,18 @@ static int find_command(int cmdchar) return idx; } +/// If currently editing a cmdline or text is locked: beep and give an error +/// message, return true. +static bool check_text_locked(oparg_T *oap) +{ + if (text_locked()) { + clearopbeep(oap); + text_locked_msg(); + return true; + } + return false; +} + /// Normal state entry point. This is called on: /// /// - Startup, In this case the function never returns. @@ -1079,15 +1091,9 @@ static int normal_execute(VimState *state, int key) goto finish; } - if (text_locked() && (nv_cmds[s->idx].cmd_flags & NV_NCW)) { - // This command is not allowed while editing a cmdline: beep. - clearopbeep(&s->oa); - text_locked_msg(); - s->command_finished = true; - goto finish; - } - - if ((nv_cmds[s->idx].cmd_flags & NV_NCW) && curbuf_locked()) { + if ((nv_cmds[s->idx].cmd_flags & NV_NCW) + && (check_text_locked(&s->oa) || curbuf_locked())) { + // this command is not allowed now s->command_finished = true; goto finish; } @@ -4704,9 +4710,7 @@ static void nv_gotofile(cmdarg_T *cap) char_u *ptr; linenr_T lnum = -1; - if (text_locked()) { - clearopbeep(cap->oap); - text_locked_msg(); + if (check_text_locked(cap->oap)) { return; } if (curbuf_locked()) { @@ -6433,13 +6437,7 @@ static void nv_g_cmd(cmdarg_T *cap) // "gQ": improved Ex mode case 'Q': - if (text_locked()) { - clearopbeep(cap->oap); - text_locked_msg(); - break; - } - - if (!checkclearopq(oap)) { + if (!check_text_locked(cap->oap) && !checkclearopq(oap)) { do_exmode(); } break; |