diff src/textformat.c @ 31825:0d27ddce621d v9.0.1245

patch 9.0.1245: code is indented more than necessary Commit: https://github.com/vim/vim/commit/032713f8299abd92fcfb1e490d1ae5c1ecadde41 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jan 25 21:05:38 2023 +0000 patch 9.0.1245: code is indented more than necessary Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11879)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Jan 2023 22:15:03 +0100
parents defef01ac8ea
children 0839c759c9d1
line wrap: on
line diff
--- a/src/textformat.c
+++ b/src/textformat.c
@@ -752,26 +752,26 @@ check_auto_format(
     int		c = ' ';
     int		cc;
 
-    if (did_add_space)
+    if (!did_add_space)
+	return;
+
+    cc = gchar_cursor();
+    if (!WHITECHAR(cc))
+	// Somehow the space was removed already.
+	did_add_space = FALSE;
+    else
     {
-	cc = gchar_cursor();
-	if (!WHITECHAR(cc))
-	    // Somehow the space was removed already.
-	    did_add_space = FALSE;
-	else
+	if (!end_insert)
 	{
-	    if (!end_insert)
-	    {
-		inc_cursor();
-		c = gchar_cursor();
-		dec_cursor();
-	    }
-	    if (c != NUL)
-	    {
-		// The space is no longer at the end of the line, delete it.
-		del_char(FALSE);
-		did_add_space = FALSE;
-	    }
+	    inc_cursor();
+	    c = gchar_cursor();
+	    dec_cursor();
+	}
+	if (c != NUL)
+	{
+	    // The space is no longer at the end of the line, delete it.
+	    del_char(FALSE);
+	    did_add_space = FALSE;
 	}
     }
 }