aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index c2e61271c7..215024f63a 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1396,7 +1396,7 @@ static void insert_do_complete(InsertState *s)
compl_cont_status = 0;
}
compl_busy = false;
- can_si = true; // allow smartindenting
+ can_si = may_do_si(); // allow smartindenting
}
static void insert_do_cindent(InsertState *s)
@@ -9344,10 +9344,8 @@ static void ins_try_si(int c)
/*
* do some very smart indenting when entering '{' or '}'
*/
- if (((did_si || can_si_back) && c == '{') || (can_si && c == '}')) {
- /*
- * for '}' set indent equal to indent of line containing matching '{'
- */
+ 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) {
old_pos = curwin->w_cursor;
/*
@@ -9403,7 +9401,7 @@ static void ins_try_si(int c)
/*
* set indent of '#' always to 0
*/
- if (curwin->w_cursor.col > 0 && can_si && c == '#') {
+ if (curwin->w_cursor.col > 0 && can_si && c == '#' && inindent(0)) {
// remember current indent for next line
old_indent = get_indent();
(void)set_indent(0, SIN_CHANGED);