diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-07-07 05:37:30 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-07-07 07:00:11 +0800 |
commit | 0612101c92f7043e47a1b4e80120582ff538c4f8 (patch) | |
tree | 694f97141c0073c4f6017da8737f32672f7e81ea /src/nvim/ex_getln.c | |
parent | df4c634d067cf01adca75abb5f38989777c5cddd (diff) | |
download | rneovim-0612101c92f7043e47a1b4e80120582ff538c4f8.tar.gz rneovim-0612101c92f7043e47a1b4e80120582ff538c4f8.tar.bz2 rneovim-0612101c92f7043e47a1b4e80120582ff538c4f8.zip |
vim-patch:8.2.5043: can open a cmdline window from a substitute expression
Problem: Can open a cmdline window from a substitute expression.
Solution: Disallow opening a command line window when text or buffer is
locked.
https://github.com/vim/vim/commit/71223e2db87c2bf3b09aecb46266b56cda26191d
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f322c46bf1..51085c4fa0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2726,6 +2726,17 @@ char *get_text_locked_msg(void) } } +/// Check for text, window or buffer locked. +/// Give an error message and return true if something is locked. +bool text_or_buf_locked(void) +{ + if (text_locked()) { + text_locked_msg(); + return true; + } + return curbuf_locked(); +} + /// Check if "curbuf->b_ro_locked" or "allbuf_lock" is set and /// return true when it is and give an error message. bool curbuf_locked(void) @@ -6600,6 +6611,11 @@ static int open_cmdwin(void) bool save_exmode = exmode_active; int save_cmdmsg_rl = cmdmsg_rl; + // Can't do this when text or buffer is locked. + if (text_or_buf_locked()) { + return K_IGNORE; + } + // Can't do this recursively. Can't do it when typing a password. if (cmdwin_type != 0 || cmdline_star > 0) { |