From 2e444bbef0f36535bf941f007f2961f3f66bbe87 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 May 2022 12:54:23 +0100 Subject: [PATCH] patch 8.2.4953: with 'si' inserting '}' after completion goes wrong Problem: With 'smartindent' inserting '}' after completion goes wrong. Solution: Check the cursor is in indent. (closes #10420) --- src/indent.c | 3 ++- src/testdir/test_smartindent.vim | 5 +++++ src/version.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/indent.c b/src/indent.c index dfc481a785..486259ef2a 100644 --- a/src/indent.c +++ b/src/indent.c @@ -1197,7 +1197,8 @@ ins_try_si(int c) int temp; // do some very smart indenting when entering '{' or '}' - if (((did_si || can_si_back) && c == '{') || (can_si && c == '}')) + if (((did_si || can_si_back) && c == '{') + || (can_si && c == '}' && inindent(0))) { // for '}' set indent equal to indent of line containing matching '{' if (c == '}' && (pos = findmatch(NULL, '{')) != NULL) diff --git a/src/testdir/test_smartindent.vim b/src/testdir/test_smartindent.vim index edfec9a809..9bb7b9c227 100644 --- a/src/testdir/test_smartindent.vim +++ b/src/testdir/test_smartindent.vim @@ -140,6 +140,11 @@ func Test_si_after_completion() call setline(1, 'foo foot') call feedkeys("o f\\#", 'tx') call assert_equal(' foo#', getline(2)) + + call setline(2, '') + call feedkeys("1Go f\\}", 'tx') + call assert_equal(' foo}', getline(2)) + bwipe! endfunc diff --git a/src/version.c b/src/version.c index 9017eeb1f5..81bbdf9583 100644 --- a/src/version.c +++ b/src/version.c @@ -746,6 +746,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 4953, /**/ 4952, /**/