diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-26 21:54:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-26 21:54:31 +0800 |
commit | 738427d4984f13ce5e7cda9cda2face9559ee7e7 (patch) | |
tree | 43c5b22693fbc81c86eda1be43a048f17a687869 /src/nvim/diff.c | |
parent | 94ce25065bb709794904b8ee96c1144006520750 (diff) | |
download | rneovim-738427d4984f13ce5e7cda9cda2face9559ee7e7.tar.gz rneovim-738427d4984f13ce5e7cda9cda2face9559ee7e7.tar.bz2 rneovim-738427d4984f13ce5e7cda9cda2face9559ee7e7.zip |
vim-patch:9.0.1098: code uses too much indent (#21540)
Problem: Code uses too much indent.
Solution: Use an early return. (Yegappan Lakshmanan, closes vim/vim#11747)
https://github.com/vim/vim/commit/465de3a57b815f1188c707e7c083950c81652536
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r-- | src/nvim/diff.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index c913260a80..267ec16d72 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1147,6 +1147,7 @@ static int diff_file(diffio_T *dio) if (dio->dio_internal) { return diff_file_internal(dio); } + const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff) + strlen(p_srr) + 27); char *const cmd = xmalloc(len); @@ -1350,30 +1351,33 @@ void ex_diffsplit(exarg_T *eap) // don't use a new tab page, each tab page has its own diffs cmdmod.cmod_tab = 0; - if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) { - // Pretend it was a ":split fname" command - eap->cmdidx = CMD_split; - curwin->w_p_diff = true; - do_exedit(eap, old_curwin); - - // split must have worked - if (curwin != old_curwin) { - // Set 'diff', 'scrollbind' on and 'wrap' off. - diff_win_options(curwin, true); - if (win_valid(old_curwin)) { - diff_win_options(old_curwin, true); + if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) == FAIL) { + return; + } - if (bufref_valid(&old_curbuf)) { - // Move the cursor position to that of the old window. - curwin->w_cursor.lnum = diff_get_corresponding_line(old_curbuf.br_buf, - old_curwin->w_cursor.lnum); - } - } - // Now that lines are folded scroll to show the cursor at the same - // relative position. - scroll_to_fraction(curwin, curwin->w_height); + // Pretend it was a ":split fname" command + eap->cmdidx = CMD_split; + curwin->w_p_diff = true; + do_exedit(eap, old_curwin); + + if (curwin == old_curwin) { // split didn't work + return; + } + + // Set 'diff', 'scrollbind' on and 'wrap' off. + diff_win_options(curwin, true); + if (win_valid(old_curwin)) { + diff_win_options(old_curwin, true); + + if (bufref_valid(&old_curbuf)) { + // Move the cursor position to that of the old window. + curwin->w_cursor.lnum = diff_get_corresponding_line(old_curbuf.br_buf, + old_curwin->w_cursor.lnum); } } + // Now that lines are folded scroll to show the cursor at the same + // relative position. + scroll_to_fraction(curwin, curwin->w_height); } // Set options to show diffs for the current window. |