aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/asan.sh28
-rw-r--r--src/nvim/ex_getln.c17
-rw-r--r--test/functional/ui/inccommand_spec.lua10
3 files changed, 42 insertions, 13 deletions
diff --git a/contrib/asan.sh b/contrib/asan.sh
new file mode 100755
index 0000000000..7e7dffa1af
--- /dev/null
+++ b/contrib/asan.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Helper script to build and run neovim with Address Sanitizer enabled.
+# You may read more information in src/nvim/README.md in the section "Build
+# with ASAN".
+
+shopt -s nullglob
+
+root_path=$(git rev-parse --show-toplevel)
+log_path=$(mktemp -d)
+export CC='clang'
+
+# Change to detect_leaks=1 to detect memory leaks (slower).
+export ASAN_OPTIONS="detect_leaks=0:log_path=$log_path/asan"
+
+# Show backtraces in the logs.
+export UBSAN_OPTIONS="print_stacktrace=1"
+
+make -C "$root_path" CMAKE_EXTRA_FLAGS="-DCLANG_ASAN_UBSAN=ON"
+VIMRUNTIME="$root_path"/runtime "$root_path"/build/bin/nvim
+
+# Need to manually reset terminal to avoid mangled output, nvim does not
+# properly restore the terminal when it crashes.
+tput reset
+
+for i in "$log_path"/*; do
+ cat "$i"
+done
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.
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index b01504db4f..a310069636 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -2051,6 +2051,16 @@ describe("'inccommand' split windows", function()
end
end)
+ it("don't open if there's not enough room", function()
+ refresh()
+ screen:try_resize(40, 3)
+ feed("gg:%s/tw")
+ screen:expect([[
+ Inc substitution on |
+ {12:tw}o lines |
+ :%s/tw^ |
+ ]])
+ end)
end)
describe("'inccommand' with 'gdefault'", function()