aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-20 07:48:52 +0800
committerGitHub <noreply@github.com>2022-12-20 07:48:52 +0800
commitb3c9563e6b7f217e4cc6c0e426af867d42b683cc (patch)
treefb612132b6d4f257d4ada5abe5c2db331c38b6e4
parent23d8f5b870ab2a12882ba20e32d24b31c137f6a9 (diff)
parentff62d761938e72129f6ba7ed2c2d56455444ebe7 (diff)
downloadrneovim-b3c9563e6b7f217e4cc6c0e426af867d42b683cc.tar.gz
rneovim-b3c9563e6b7f217e4cc6c0e426af867d42b683cc.tar.bz2
rneovim-b3c9563e6b7f217e4cc6c0e426af867d42b683cc.zip
Merge pull request #21477 from zeertzjq/vim-9.0.1078
vim-patch:9.0.{1078,1079}
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/testdir/test_fold.vim21
-rw-r--r--src/nvim/testdir/test_usercommands.vim5
-rw-r--r--src/nvim/usercmd.c9
4 files changed, 34 insertions, 3 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 2777ebd18c..7d3b1f4a3f 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -378,7 +378,7 @@ int get_indent_lnum(linenr_T lnum)
int get_indent_buf(buf_T *buf, linenr_T lnum)
{
return get_indent_str_vtab(ml_get_buf(buf, lnum, false),
- curbuf->b_p_ts,
+ buf->b_p_ts,
buf->b_p_vts_array,
false);
}
diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim
index d74187537c..f19e4c8253 100644
--- a/src/nvim/testdir/test_fold.vim
+++ b/src/nvim/testdir/test_fold.vim
@@ -157,6 +157,27 @@ func Test_indent_fold_max()
bw!
endfunc
+func Test_indent_fold_tabstop()
+ call setline(1, ['0', ' 1', ' 1', "\t2", "\t2"])
+ setlocal shiftwidth=4
+ setlocal foldcolumn=1
+ setlocal foldlevel=2
+ setlocal foldmethod=indent
+ redraw
+ call assert_equal('2 2', ScreenLines(5, 10)[0])
+ vsplit
+ windo diffthis
+ botright new
+ " This 'tabstop' value should not be used for folding in other buffers.
+ setlocal tabstop=4
+ diffoff!
+ redraw
+ call assert_equal('2 2', ScreenLines(5, 10)[0])
+
+ bwipe!
+ bwipe!
+endfunc
+
func Test_manual_fold_with_filter()
CheckExecutable cat
for type in ['manual', 'marker']
diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim
index 6a985d78aa..3ae990e022 100644
--- a/src/nvim/testdir/test_usercommands.vim
+++ b/src/nvim/testdir/test_usercommands.vim
@@ -323,6 +323,11 @@ func Test_CmdErrors()
call assert_fails('com DoCmd :', 'E174:')
comclear
call assert_fails('delcom DoCmd', 'E184:')
+
+ " These used to leak memory
+ call assert_fails('com! -complete=custom,CustomComplete _ :', 'E182:')
+ call assert_fails('com! -complete=custom,CustomComplete docmd :', 'E183:')
+ call assert_fails('com! -complete=custom,CustomComplete -xxx DoCmd :', 'E181:')
endfunc
func CustomComplete(A, L, P)
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index ca5307fe24..bc47b1b807 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -943,7 +943,7 @@ void ex_command(exarg_T *eap)
end = skiptowhite(p);
if (uc_scan_attr(p, (size_t)(end - p), &argt, &def, &flags, &compl, (char_u **)&compl_arg,
&addr_type_arg) == FAIL) {
- return;
+ goto theend;
}
p = skipwhite(end);
}
@@ -953,7 +953,7 @@ void ex_command(exarg_T *eap)
end = uc_validate_name(name);
if (!end) {
emsg(_("E182: Invalid command name"));
- return;
+ goto theend;
}
name_len = (size_t)(end - name);
@@ -971,7 +971,12 @@ void ex_command(exarg_T *eap)
} else {
uc_add_command(name, name_len, p, argt, def, flags, compl, compl_arg, LUA_NOREF, LUA_NOREF,
addr_type_arg, LUA_NOREF, eap->forceit);
+
+ return; // success
}
+
+theend:
+ xfree(compl_arg);
}
/// ":comclear"