aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@protonmail.com>2022-06-12 23:59:04 +0600
committerGitHub <noreply@github.com>2022-06-12 10:59:04 -0700
commit2de0d6714497e4259f467516e52852c1016d5318 (patch)
tree9de048c5eece4b0b7d66b9d0815da41c0ea02c35 /src
parentf4967828f905fa055d0e69d48a7d735d7f967e1e (diff)
downloadrneovim-2de0d6714497e4259f467516e52852c1016d5318.tar.gz
rneovim-2de0d6714497e4259f467516e52852c1016d5318.tar.bz2
rneovim-2de0d6714497e4259f467516e52852c1016d5318.zip
fix(inccommand): skip split window if not enough room #18937
Command preview now behaves like inccommand=nosplit when there's not enough room for the preview window to be opened instead of aborting, which is consistent with old behavior of 'inccommand'.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_getln.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 5bca6b5f81..94ce1ec495 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2325,19 +2325,9 @@ static buf_T *cmdpreview_open_buf(void)
static win_T *cmdpreview_open_win(buf_T *cmdpreview_buf)
{
win_T *save_curwin = curwin;
- bool win_found = false;
- // Try to find an existing preview window.
- FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
- if (wp->w_buffer == cmdpreview_buf) {
- win_enter(wp, false);
- win_found = true;
- break;
- }
- }
-
- // If an existing window is not found, create one.
- if (!win_found && win_split((int)p_cwh, WSP_BOT) == FAIL) {
+ // Open preview window.
+ if (win_split((int)p_cwh, WSP_BOT) == FAIL) {
return NULL;
}
@@ -2459,7 +2449,8 @@ static void cmdpreview_show(CommandLineState *s)
// If inccommand=split and preview callback returns 2, open preview window.
if (icm_split && cmdpreview_type == 2
&& (cmdpreview_win = cmdpreview_open_win(cmdpreview_buf)) == NULL) {
- abort();
+ // If there's not enough room to open the preview window, just preview without the window.
+ cmdpreview_type = 1;
}
// If preview callback is nonzero, update screen now.