summaryrefslogtreecommitdiffstats
path: root/src/indent.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-14 11:52:23 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-14 11:52:23 +0100
commitde5cf287812510d2c8ffe66b99cf33c4e1a6e6f1 (patch)
tree1da7638f0773297167182c800faa03b20f7acdb3 /src/indent.c
parent4b93674159d60c985de906c30f45dbaf2b64056f (diff)
patch 8.2.4951: smart indenting done when not enabledv8.2.4951
Problem: Smart indenting done when not enabled. Solution: Check option values before setting can_si. (closes #10420)
Diffstat (limited to 'src/indent.c')
-rw-r--r--src/indent.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/indent.c b/src/indent.c
index 06d98f92ec..dfc481a785 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1169,6 +1169,22 @@ preprocs_left(void)
#ifdef FEAT_SMARTINDENT
/*
+ * Return TRUE if the conditions are OK for smart indenting.
+ */
+ int
+may_do_si()
+{
+ return curbuf->b_p_si
+# ifdef FEAT_CINDENT
+ && !curbuf->b_p_cin
+# endif
+# ifdef FEAT_EVAL
+ && *curbuf->b_p_inde == NUL
+# endif
+ && !p_paste;
+}
+
+/*
* Try to do some very smart auto-indenting.
* Used when inserting a "normal" character.
*/
@@ -1235,7 +1251,7 @@ 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();