comparison src/session.c @ 31809:543153d582d5 v9.0.1237

patch 9.0.1237: code is indented more than necessary Commit: https://github.com/vim/vim/commit/6ec66660476562e643deceb7c325cd0e8c903663 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Jan 23 20:46:21 2023 +0000 patch 9.0.1237: 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 #11858)
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Jan 2023 22:00:04 +0100
parents 029c59bf78f1
children 04d9dff67d99
comparison
equal deleted inserted replaced
31808:e1d9d84d0eba 31809:543153d582d5
198 ses_win_rec(FILE *fd, frame_T *fr) 198 ses_win_rec(FILE *fd, frame_T *fr)
199 { 199 {
200 frame_T *frc; 200 frame_T *frc;
201 int count = 0; 201 int count = 0;
202 202
203 if (fr->fr_layout != FR_LEAF) 203 if (fr->fr_layout == FR_LEAF)
204 { 204 return OK;
205 // Find first frame that's not skipped and then create a window for 205
206 // each following one (first frame is already there). 206 // Find first frame that's not skipped and then create a window for
207 frc = ses_skipframe(fr->fr_child); 207 // each following one (first frame is already there).
208 if (frc != NULL) 208 frc = ses_skipframe(fr->fr_child);
209 while ((frc = ses_skipframe(frc->fr_next)) != NULL) 209 if (frc != NULL)
210 { 210 while ((frc = ses_skipframe(frc->fr_next)) != NULL)
211 // Make window as big as possible so that we have lots of room 211 {
212 // to split. 212 // Make window as big as possible so that we have lots of room
213 if (put_line(fd, "wincmd _ | wincmd |") == FAIL 213 // to split.
214 || put_line(fd, fr->fr_layout == FR_COL 214 if (put_line(fd, "wincmd _ | wincmd |") == FAIL
215 ? "split" : "vsplit") == FAIL) 215 || put_line(fd, fr->fr_layout == FR_COL
216 return FAIL; 216 ? "split" : "vsplit") == FAIL)
217 ++count; 217 return FAIL;
218 } 218 ++count;
219 219 }
220 // Go back to the first window. 220
221 if (count > 0 && (fprintf(fd, fr->fr_layout == FR_COL 221 // Go back to the first window.
222 ? "%dwincmd k" : "%dwincmd h", count) < 0 222 if (count > 0 && (fprintf(fd, fr->fr_layout == FR_COL
223 || put_eol(fd) == FAIL)) 223 ? "%dwincmd k" : "%dwincmd h", count) < 0
224 || put_eol(fd) == FAIL))
225 return FAIL;
226
227 // Recursively create frames/windows in each window of this column or
228 // row.
229 frc = ses_skipframe(fr->fr_child);
230 while (frc != NULL)
231 {
232 ses_win_rec(fd, frc);
233 frc = ses_skipframe(frc->fr_next);
234 // Go to next window.
235 if (frc != NULL && put_line(fd, "wincmd w") == FAIL)
224 return FAIL; 236 return FAIL;
225 237 }
226 // Recursively create frames/windows in each window of this column or 238
227 // row.
228 frc = ses_skipframe(fr->fr_child);
229 while (frc != NULL)
230 {
231 ses_win_rec(fd, frc);
232 frc = ses_skipframe(frc->fr_next);
233 // Go to next window.
234 if (frc != NULL && put_line(fd, "wincmd w") == FAIL)
235 return FAIL;
236 }
237 }
238 return OK; 239 return OK;
239 } 240 }
240 241
241 static int 242 static int
242 ses_winsizes( 243 ses_winsizes(
1066 ex_loadview(exarg_T *eap) 1067 ex_loadview(exarg_T *eap)
1067 { 1068 {
1068 char_u *fname; 1069 char_u *fname;
1069 1070
1070 fname = get_view_file(*eap->arg); 1071 fname = get_view_file(*eap->arg);
1071 if (fname != NULL) 1072 if (fname == NULL)
1072 { 1073 return;
1073 do_source(fname, FALSE, DOSO_NONE, NULL); 1074
1074 vim_free(fname); 1075 do_source(fname, FALSE, DOSO_NONE, NULL);
1075 } 1076 vim_free(fname);
1076 } 1077 }
1077 1078
1078 # if defined(FEAT_GUI_GNOME) \ 1079 # if defined(FEAT_GUI_GNOME) \
1079 || (defined(GUI_MAY_SPAWN) && defined(EXPERIMENTAL_GUI_CMD)) \ 1080 || (defined(GUI_MAY_SPAWN) && defined(EXPERIMENTAL_GUI_CMD)) \
1080 || defined(PROTO) 1081 || defined(PROTO)