summaryrefslogtreecommitdiffstats
path: root/src/fold.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-01-08 13:44:24 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-08 13:44:24 +0000
commit7f8b2559a30e2e2a443c35b28e94c6b45ba7ae04 (patch)
tree04c0145c1e3cf9777d58c91fa7b2ad231cfecf8d /src/fold.c
parentdf8f9473596c8fb18ec893de677dba455e8925b3 (diff)
patch 9.0.1158: code is indented more than necessaryv9.0.1158
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11787)
Diffstat (limited to 'src/fold.c')
-rw-r--r--src/fold.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/fold.c b/src/fold.c
index d722a56d0c..61bffb5d01 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -513,13 +513,14 @@ newFoldLevelWin(win_T *wp)
void
foldCheckClose(void)
{
- if (*p_fcl != NUL) // can only be "all" right now
- {
- checkupdate(curwin);
- if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
- (int)curwin->w_p_fdl))
- changed_window_setting();
- }
+ if (*p_fcl == NUL)
+ return;
+
+ // can only be "all" right now
+ checkupdate(curwin);
+ if (checkCloseRec(&curwin->w_folds, curwin->w_cursor.lnum,
+ (int)curwin->w_p_fdl))
+ changed_window_setting();
}
// checkCloseRec() {{{2
@@ -1077,16 +1078,17 @@ foldAdjustVisual(void)
}
if (hasFolding(start->lnum, &start->lnum, NULL))
start->col = 0;
- if (hasFolding(end->lnum, NULL, &end->lnum))
- {
- ptr = ml_get(end->lnum);
- end->col = (colnr_T)STRLEN(ptr);
- if (end->col > 0 && *p_sel == 'o')
- --end->col;
- // prevent cursor from moving on the trail byte
- if (has_mbyte)
- mb_adjust_cursor();
- }
+
+ if (!hasFolding(end->lnum, NULL, &end->lnum))
+ return;
+
+ ptr = ml_get(end->lnum);
+ end->col = (colnr_T)STRLEN(ptr);
+ if (end->col > 0 && *p_sel == 'o')
+ --end->col;
+ // prevent cursor from moving on the trail byte
+ if (has_mbyte)
+ mb_adjust_cursor();
}
// cursor_foldstart() {{{2
@@ -1215,11 +1217,11 @@ foldLevelWin(win_T *wp, linenr_T lnum)
static void
checkupdate(win_T *wp)
{
- if (wp->w_foldinvalid)
- {
- foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); // will update all
- wp->w_foldinvalid = FALSE;
- }
+ if (!wp->w_foldinvalid)
+ return;
+
+ foldUpdate(wp, (linenr_T)1, (linenr_T)MAXLNUM); // will update all
+ wp->w_foldinvalid = FALSE;
}
// setFoldRepeat() {{{2