patch 8.2.4951: smart indenting done when not enabled

Problem:    Smart indenting done when not enabled.
Solution:   Check option values before setting can_si. (closes #10420)
diff --git a/src/indent.c b/src/indent.c
index 06d98f9..dfc481a 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1169,6 +1169,22 @@
 
 #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 @@
     }
 
     // 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();