diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-16 18:19:05 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-16 18:19:05 +0000 |
commit | a41e221935edab62672a15123af48f4f14ac1c7d (patch) | |
tree | 318664da494793bc3edfd6ffafc9d9ed53971dd5 /src | |
parent | 450c7a97d1a28f715acaf562298112b9b932adc3 (diff) |
patch 9.0.1208: code is indented more than necessaryv9.0.1208
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11819)
Diffstat (limited to 'src')
-rw-r--r-- | src/netbeans.c | 175 | ||||
-rw-r--r-- | src/normal.c | 804 | ||||
-rw-r--r-- | src/ops.c | 51 | ||||
-rw-r--r-- | src/option.c | 93 | ||||
-rw-r--r-- | src/optionstr.c | 206 | ||||
-rw-r--r-- | src/os_amiga.c | 107 | ||||
-rw-r--r-- | src/os_mac_conv.c | 34 | ||||
-rw-r--r-- | src/os_mswin.c | 154 | ||||
-rw-r--r-- | src/os_qnx.c | 50 | ||||
-rw-r--r-- | src/os_unix.c | 511 | ||||
-rw-r--r-- | src/os_win32.c | 371 | ||||
-rw-r--r-- | src/version.c | 2 |
12 files changed, 1282 insertions, 1276 deletions
diff --git a/src/netbeans.c b/src/netbeans.c index 523cda08d7..56a25829fa 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -938,13 +938,13 @@ nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last) if (lastbyte >= oldlen) lastbyte = oldlen - 1; newtext = alloc(oldlen - (int)(lastbyte - first)); - if (newtext != NULL) - { - mch_memmove(newtext, oldtext, first); - STRMOVE(newtext + first, oldtext + lastbyte + 1); - nbdebug((" NEW LINE %ld: %s\n", lnum, newtext)); - ml_replace(lnum, newtext, FALSE); - } + if (newtext == NULL) + return; + + mch_memmove(newtext, oldtext, first); + STRMOVE(newtext + first, oldtext + lastbyte + 1); + nbdebug((" NEW LINE %ld: %s\n", lnum, newtext)); + ml_replace(lnum, newtext, FALSE); } /* @@ -960,12 +960,12 @@ nb_joinlines(linenr_T first, linenr_T other) len_first = (int)STRLEN(ml_get(first)); len_other = (int)STRLEN(ml_get(other)); p = alloc(len_first + len_other + 1); - if (p != NULL) - { - mch_memmove(p, ml_get(first), len_first); - mch_memmove(p + len_first, ml_get(other), len_other + 1); - ml_replace(first, p, FALSE); - } + if (p == NULL) + return; + + mch_memmove(p, ml_get(first), len_first); + mch_memmove(p + len_first, ml_get(other), len_other + 1); + ml_replace(first, p, FALSE); } #define SKIP_STOP 2 @@ -2247,13 +2247,14 @@ nb_do_cmd( static void nb_set_curbuf(buf_T *buf) { - if (curbuf != buf) { - if (buf_jump_open_win(buf) != NULL) - return; - if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL) - return; - set_curbuf(buf, DOBUF_GOTO); - } + if (curbuf == buf) + return; + + if (buf_jump_open_win(buf) != NULL) + return; + if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf) != NULL) + return; + set_curbuf(buf, DOBUF_GOTO); } /* @@ -2364,14 +2365,14 @@ nb_init_graphics(void) { static int did_init = FALSE; - if (!did_init) - { - coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black" - " ctermbg=LightCyan ctermfg=Black"); - coloncmd(":sign define %d linehl=NBGuarded", GUARDED); + if (did_init) + return; - did_init = TRUE; - } + coloncmd(":highlight NBGuarded guibg=Cyan guifg=Black" + " ctermbg=LightCyan ctermfg=Black"); + coloncmd(":sign define %d linehl=NBGuarded", GUARDED); + + did_init = TRUE; } /* @@ -2468,29 +2469,29 @@ netbeans_beval_cb( if (!can_use_beval() || !NETBEANS_OPEN) return; - if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK) + if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) != OK) + return; + + // Send debugger request. Only when the text is of reasonable + // length. + if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL) { - // Send debugger request. Only when the text is of reasonable - // length. - if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL) + buf = alloc(MAXPATHL * 2 + 25); + if (buf != NULL) { - buf = alloc(MAXPATHL * 2 + 25); - if (buf != NULL) + p = nb_quote(text); + if (p != NULL) { - p = nb_quote(text); - if (p != NULL) - { - vim_snprintf(buf, MAXPATHL * 2 + 25, - "0:balloonText=%d \"%s\"\n", r_cmdno, p); - vim_free(p); - } - nbdebug(("EVT: %s", buf)); - nb_send(buf, "netbeans_beval_cb"); - vim_free(buf); + vim_snprintf(buf, MAXPATHL * 2 + 25, + "0:balloonText=%d \"%s\"\n", r_cmdno, p); + vim_free(p); } + nbdebug(("EVT: %s", buf)); + nb_send(buf, "netbeans_beval_cb"); + vim_free(buf); } - vim_free(text); } + vim_free(text); } #endif @@ -2555,12 +2556,12 @@ set_ref_in_nb_channel(int copyID) int abort = FALSE; typval_T tv; - if (nb_channel != NULL) - { - tv.v_type = VAR_CHANNEL; - tv.vval.v_channel = nb_channel; - abort = set_ref_in_item(&tv, copyID, NULL, NULL); - } + if (nb_channel == NULL) + return FALSE; + + tv.v_type = VAR_CHANNEL; + tv.vval.v_channel = nb_channel; + abort = set_ref_in_item(&tv, copyID, NULL, NULL); return abort; } #endif @@ -2827,22 +2828,22 @@ netbeans_button_release(int button) bufno = nb_getbufno(curbuf); - if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf) - { - int col = mouse_col - curwin->w_wincol - - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1); - long off = pos2off(curbuf, &curwin->w_cursor); + if (bufno < 0 || curwin == NULL || curwin->w_buffer != curbuf) + return; - // sync the cursor position - sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off); - nbdebug(("EVT: %s", buf)); - nb_send(buf, "netbeans_button_release[newDotAndMark]"); + int col = mouse_col - curwin->w_wincol + - ((curwin->w_p_nu || curwin->w_p_rnu) ? 9 : 1); + long off = pos2off(curbuf, &curwin->w_cursor); - sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno, - button, (long)curwin->w_cursor.lnum, col); - nbdebug(("EVT: %s", buf)); - nb_send(buf, "netbeans_button_release"); - } + // sync the cursor position + sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off); + nbdebug(("EVT: %s", buf)); + nb_send(buf, "netbeans_button_release[newDotAndMark]"); + + sprintf(buf, "%d:buttonRelease=%d %d %ld %d\n", bufno, r_cmdno, + button, (long)curwin->w_cursor.lnum, col); + nbdebug(("EVT: %s", buf)); + nb_send(buf, "netbeans_button_release"); } @@ -3308,29 +3309,27 @@ get_buf_size(buf_T *bufp) if (bufp->b_ml.ml_flags & ML_EMPTY) return 0; + + if (get_fileformat(bufp) == EOL_DOS) + eol_size = 2; else + eol_size = 1; + for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum) { - if (get_fileformat(bufp) == EOL_DOS) - eol_size = 2; - else - eol_size = 1; - for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum) + char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE)) + + eol_size; + // Check for a CTRL-C every 100000 characters + if (char_count > last_check) { - char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE)) - + eol_size; - // Check for a CTRL-C every 100000 characters - if (char_count > last_check) - { - ui_breakcheck(); - if (got_int) - return char_count; - last_check = char_count + 100000L; - } + ui_breakcheck(); + if (got_int) + return char_count; + last_check = char_count + 100000L; } - // Correction for when last line doesn't have an EOL. - if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol)) - char_count -= eol_size; } + // Correction for when last line doesn't have an EOL. + if (!bufp->b_p_eol && (bufp->b_p_bin || !bufp->b_p_fixeol)) + char_count -= eol_size; return char_count; } @@ -3393,12 +3392,12 @@ pos2off(buf_T *buf, pos_T *pos) { long offset = 0; - if (!(buf->b_ml.ml_flags & ML_EMPTY)) - { - if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0) - return 0; - offset += pos->col; - } + if (buf->b_ml.ml_flags & ML_EMPTY) + return 0; + + if ((offset = ml_find_line_or_offset(buf, pos->lnum, 0)) < 0) + return 0; + offset += pos->col; return offset; } diff --git a/src/normal.c b/src/normal.c index 3d9f74dec5..0bd6655f2d 100644 --- a/src/normal.c +++ b/src/normal.c @@ -186,14 +186,13 @@ find_command(int cmdchar) static int check_text_locked(oparg_T *oap) { - if (text_locked()) - { - if (oap != NULL) - clearopbeep(oap); - text_locked_msg(); - return TRUE; - } - return FALSE; + if (!text_locked()) + return FALSE; + + if (oap != NULL) + clearopbeep(oap); + text_locked_msg(); + return TRUE; } /* @@ -206,13 +205,13 @@ check_text_or_curbuf_locked(oparg_T *oap) { if (check_text_locked(oap)) return TRUE; - if (curbuf_locked()) - { - if (oap != NULL) - clearop(oap); - return TRUE; - } - return FALSE; + + if (!curbuf_locked()) + return FALSE; + + if (oap != NULL) + clearop(oap); + return TRUE; } /* @@ -2030,19 +2029,19 @@ nv_addsub(cmdarg_T *cap) static void nv_page(cmdarg_T *cap) { - if (!checkclearop(cap->oap)) + if (checkclearop(cap->oap)) + return; + + if (mod_mask & MOD_MASK_CTRL) { - if (mod_mask & MOD_MASK_CTRL) - { - // <C-PageUp>: tab page back; <C-PageDown>: tab page forward - if (cap->arg == BACKWARD) - goto_tabpage(-(int)cap->count1); - else - goto_tabpage((int)cap->count0); - } + // <C-PageUp>: tab page back; <C-PageDown>: tab page forward + if (cap->arg == BACKWARD) + goto_tabpage(-(int)cap->count1); else - (void)onepage(cap->arg, cap->count1); + goto_tabpage((int)cap->count0); } + else + (void)onepage(cap->arg, cap->count1); } /* @@ -2062,17 +2061,16 @@ nv_gd( == FAIL) { clearopbeep(oap); + return; } - else - { + #ifdef FEAT_FOLDING - if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) - foldOpenCursor(); + if ((fdo_flags & FDO_SEARCH) && KeyTyped && oap->op_type == OP_NOP) + foldOpenCursor(); #endif - // clear any search statistics - if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT)) - clear_cmdline = TRUE; - } + // clear any search statistics + if (messaging() && !msg_silent && !shortmess(SHM_SEARCHCOUNT)) + clear_cmdline = TRUE; } /* @@ -3157,60 +3155,61 @@ nv_colon(cmdarg_T *cap) int flags; if (VIsual_active && !is_cmdkey) + { nv_operator(cap); - else + return; + } + + if (cap->oap->op_type != OP_NOP) { - if (cap->oap->op_type != OP_NOP) + // Using ":" as a movement is characterwise exclusive. + cap->oap->motion_type = MCHAR; + cap->oap->inclusive = FALSE; + } + else if (cap->count0 && !is_cmdkey) + { + // translate "count:" into ":.,.+(count - 1)" + stuffcharReadbuff('.'); + if (cap->count0 > 1) { - // Using ":" as a movement is characterwise exclusive. - cap->oap->motion_type = MCHAR; - cap->oap->inclusive = FALSE; + stuffReadbuff((char_u *)",.+"); + stuffnumReadbuff((long)cap->count0 - 1L); } - else if (cap->count0 && !is_cmdkey) - { - // translate "count:" into ":.,.+(count - 1)" - stuffcharReadbuff('.'); - if (cap->count0 > 1) - { - stuffReadbuff((char_u *)",.+"); - stuffnumReadbuff((long)cap->count0 - 1L); - } - } - - // When typing, don't type below an old message - if (KeyTyped) - compute_cmdrow(); + } - old_p_im = p_im; + // When typing, don't type below an old message + if (KeyTyped) + compute_cmdrow(); - // get a command line and execute it - flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0; - if (is_cmdkey) - cmd_result = do_cmdkey_command(cap->cmdchar, flags); - else - cmd_result = do_cmdline(NULL, getexline, NULL, flags); + old_p_im = p_im; - // If 'insertmode' changed, enter or exit Insert mode - if (p_im != old_p_im) - { - if (p_im) - restart_edit = 'i'; - else - restart_edit = 0; - } + // get a command line and execute it + flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0; + if (is_cmdkey) + cmd_result = do_cmdkey_command(cap->cmdchar, flags); + else + cmd_result = do_cmdline(NULL, getexline, NULL, flags); - if (cmd_result == FAIL) - // The Ex command failed, do not execute the operator. - clearop(cap->oap); - else if (cap->oap->op_type != OP_NOP - && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count - || cap->oap->start.col > - (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) - || did_emsg - )) - // The start of the operator has become invalid by the Ex command. - clearopbeep(cap->oap); + // If 'insertmode' changed, enter or exit Insert mode + if (p_im != old_p_im) + { + if (p_im) + restart_edit = 'i'; + else + restart_edit = 0; } + + if (cmd_result == FAIL) + // The Ex command failed, do not execute the operator. + clearop(cap->oap); + else if (cap->oap->op_type != OP_NOP + && (cap->oap->start.lnum > curbuf->b_ml.ml_line_count + || cap->oap->start.col > + (colnr_T)STRLEN(ml_get(cap->oap->start.lnum)) + || did_emsg + )) + // The start of the operator has become invalid by the Ex command. + clearopbeep(cap->oap); } /* @@ -3251,28 +3250,28 @@ nv_ctrlh(cmdarg_T *cap) static void nv_clear(cmdarg_T *cap) { - if (!checkclearop(cap->oap)) - { + if (checkclearop(cap->oap)) + return; + #ifdef FEAT_SYN_HL - // Clear all syntax states to force resyncing. - syn_stack_free_all(curwin->w_s); + // Clear all syntax states to force resyncing. + syn_stack_free_all(curwin->w_s); # ifdef FEAT_RELTIME - { - win_T *wp; + { + win_T *wp; - FOR_ALL_WINDOWS(wp) - wp->w_s->b_syn_slow = FALSE; - } + FOR_ALL_WINDOWS(wp) + wp->w_s->b_syn_slow = FALSE; + } # endif #endif - redraw_later(UPD_CLEAR); + redraw_later(UPD_CLEAR); #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL)) # ifdef VIMDLL - if (!gui.in_use) + if (!gui.in_use) # endif - resize_console_buf(); + resize_console_buf(); #endif - } } /* @@ -3314,20 +3313,20 @@ nv_hat(cmdarg_T *cap) static void nv_Zet(cmdarg_T *cap) { - if (!checkclearopq(cap->oap)) + if (checkclearopq(cap->oap)) + return; + + switch (cap->nchar) { - switch (cap->nchar) - { - // "ZZ": equivalent to ":x". - case 'Z': do_cmdline_cmd((char_u *)"x"); + // "ZZ": equivalent to ":x". + case 'Z': do_cmdline_cmd((char_u *)"x"); break; // "ZQ": equivalent to ":q!" (Elvis compatible). - case 'Q': do_cmdline_cmd((char_u *)"q!"); + case 'Q': do_cmdline_cmd((char_u *)"q!"); break; - default: clearopbeep(cap->oap); - } + default: clearopbeep(cap->oap); } } @@ -3982,15 +3981,14 @@ nv_up(cmdarg_T *cap) // <S-Up> is page up cap->arg = BACKWARD; nv_page(cap); + return; } - else - { - cap->oap->motion_type = MLINE; - if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) - clearopbeep(cap->oap); - else if (cap->arg) - beginline(BL_WHITE | BL_FIX); - } + + cap->oap->motion_type = MLINE; + if (cursor_up(cap->count1, cap->oap->op_type == OP_NOP) == FAIL) + clearopbeep(cap->oap); + else if (cap->arg) + beginline(BL_WHITE | BL_FIX); } /* @@ -4249,27 +4247,28 @@ nv_csearch(cmdarg_T *cap) cap->oap->motion_type = MCHAR; if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL) + { clearopbeep(cap->oap); - else + return; + } + + curwin->w_set_curswant = TRUE; + // Include a Tab for "tx" and for "dfx". + if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD + && (t_cmd || cap->oap->op_type != OP_NOP)) { - curwin->w_set_curswant = TRUE; - // Include a Tab for "tx" and for "dfx". - if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD - && (t_cmd || cap->oap->op_type != OP_NOP)) - { - colnr_T scol, ecol; + colnr_T scol, ecol; - getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); - curwin->w_cursor.coladd = ecol - scol; - } - else - curwin->w_cursor.coladd = 0; - adjust_for_sel(cap); + getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); + curwin->w_cursor.coladd = ecol - scol; + } + else + curwin->w_cursor.coladd = 0; + adjust_for_sel(cap); #ifdef FEAT_FOLDING - if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) - foldOpenCursor(); + if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) + foldOpenCursor(); #endif - } } /* @@ -4654,17 +4653,18 @@ nv_brace(cmdarg_T *cap) curwin->w_set_curswant = TRUE; if (findsent(cap->arg, cap->count1) == FAIL) - clearopbeep(cap->oap); - else { - // Don't leave the cursor on the NUL past end of line. - adjust_cursor(cap->oap); - curwin->w_cursor.coladd = 0; + clearopbeep(cap->oap); + return; + } + + // Don't leave the cursor on the NUL past end of line. + adjust_cursor(cap->oap); + curwin->w_cursor.coladd = 0; #ifdef FEAT_FOLDING - if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) - foldOpenCursor(); + if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) + foldOpenCursor(); #endif - } } /* @@ -4673,11 +4673,11 @@ nv_brace(cmdarg_T *cap) static void nv_mark(cmdarg_T *cap) { - if (!checkclearop(cap->oap)) - { - if (setmark(cap->nchar) == FAIL) - clearopbeep(cap->oap); - } + if (checkclearop(cap->oap)) + return; + + if (setmark(cap->nchar) == FAIL) + clearopbeep(cap->oap); } /* @@ -4692,15 +4692,16 @@ nv_findpar(cmdarg_T *cap) cap->oap->use_reg_one = TRUE; curwin->w_set_curswant = TRUE; if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE)) - clearopbeep(cap->oap); - else { - curwin->w_cursor.coladd = 0; + clearopbeep(cap->oap); + return; + } + + curwin->w_cursor.coladd = 0; #ifdef FEAT_FOLDING - if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) - foldOpenCursor(); + if ((fdo_flags & FDO_BLOCK) && KeyTyped && cap->oap->op_type == OP_NOP) + foldOpenCursor(); #endif - } } /* @@ -4726,18 +4727,18 @@ nv_undo(cmdarg_T *cap) static void nv_kundo(cmdarg_T *cap) { - if (!checkclearopq(cap->oap)) - { + if (checkclearopq(cap->oap)) + return; + #ifdef FEAT_JOB_CHANNEL - if (bt_prompt(curbuf)) - { - clearopbeep(cap->oap); - return; - } -#endif - u_undo((int)cap->count1); - curwin->w_set_curswant = TRUE; + if (bt_prompt(curbuf)) + { + clearopbeep(cap->oap); + return; } +#endif + u_undo((int)cap->count1); + curwin->w_set_curswant = TRUE; } /* @@ -5008,17 +5009,19 @@ nv_Replace(cmdarg_T *cap) VIsual_mode_orig = VIsual_mode; // remember original area for gv VIsual_mode = 'V'; nv_operator(cap); + return; } - else if (!checkclearopq(cap->oap)) + + if (checkclearopq(cap->oap)) + return; + + if (!curbuf->b_p_ma) + emsg(_(e_cannot_make_changes_modifiable_is_off)); + else { - if (!curbuf->b_p_ma) - emsg(_(e_cannot_make_changes_modifiable_is_off)); - else - { - if (virtual_active()) - coladvance(getviscol()); - invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); - } + if (virtual_active()) + coladvance(getviscol()); + invoke_edit(cap, FALSE, cap->arg ? 'V' : 'R', FALSE); } } @@ -5033,21 +5036,23 @@ nv_vreplace(cmdarg_T *cap) cap->cmdchar = 'r'; cap->nchar = cap->extra_char; nv_replace(cap); // Do same as "r" in Visual mode for now + return; } - else if (!checkclearopq(cap->oap)) + + if (checkclearopq(cap->oap)) + return; + + if (!curbuf->b_p_ma) + emsg(_(e_cannot_make_changes_modifiable_is_off)); + else { - if (!curbuf->b_p_ma) - emsg(_(e_cannot_make_changes_modifiable_is_off)); - else - { - if (cap->extra_char == Ctrl_V) // get another character - cap->extra_char = get_literal(FALSE); - stuffcharReadbuff(cap->extra_char); - stuffcharReadbuff(ESC); - if (virtual_active()) - coladvance(getviscol()); - invoke_edit(cap, TRUE, 'v', FALSE); - } + if (cap->extra_char == Ctrl_V) // get another character + cap->extra_char = get_literal(FALSE); + stuffcharReadbuff(cap->extra_char); + stuffcharReadbuff(ESC); + if (virtual_active()) + coladvance(getviscol()); + invoke_edit(cap, TRUE, 'v', FALSE); } } @@ -5345,44 +5350,44 @@ nv_pcmark(cmdarg_T *cap) int old_KeyTyped = KeyTyped; // getting file may reset it #endif - if (!checkclearopq(cap->oap)) + if (checkclearopq(cap->oap)) + return; + + if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL) { - if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL) - { - if (goto_tabpage_lastused() == FAIL) - clearopbeep(cap->oap); - return; - } - if (cap->cmdchar == 'g') - pos = movechangelist((int)cap->count1); - else - pos = movemark((int)cap->count1); - if (pos == (pos_T *)-1) // jump to other file - { - curwin->w_set_curswant = TRUE; - check_cursor(); - } - else if (pos != NULL) // can jump - nv_cursormark(cap, FALSE, pos); - else if (cap->cmdchar == 'g') - { - if (curbuf->b_changelistlen == 0) - emsg(_(e_changelist_is_empty)); - else if (cap->count1 < 0) - emsg(_(e_at_start_of_changelist)); - else - emsg(_(e_at_end_of_changelist)); - } - else + if (goto_tabpage_lastused() == FAIL) clearopbeep(cap->oap); + return; + } + if (cap->cmdchar == 'g') + pos = movechangelist((int)cap->count1); + else + pos = movemark((int)cap->count1); + if (pos == (pos_T *)-1) // jump to other file + { + curwin->w_set_curswant = TRUE; + check_cursor(); + } + else if (pos != NULL) // can jump + nv_cursormark(cap, FALSE, pos); + else if (cap->cmdchar == 'g') + { + if (curbuf->b_changelistlen == 0) + emsg(_(e_changelist_is_empty)); + else if (cap->count1 < 0) + emsg(_(e_at_start_of_changelist)); + else + emsg(_(e_at_end_of_changelist)); + } + else + clearopbeep(cap->oap); # ifdef FEAT_FOLDING - if (cap->oap->op_type == OP_NOP - && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum) - && (fdo_flags & FDO_MARK) - && old_KeyTyped) - foldOpenCursor(); + if (cap->oap->op_type == OP_NOP + && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum) + && (fdo_flags & FDO_MARK) + && old_KeyTyped) + foldOpenCursor(); # endif - } } /* @@ -6237,41 +6242,41 @@ n_opencmd(cmdarg_T *cap) linenr_T oldline = curwin->w_cursor.lnum; #endif - if (!checkclearopq(cap->oap)) - { + if (checkclearopq(cap->oap)) + return; + #ifdef FEAT_FOLDING - if (cap->cmdchar == 'O') - // Open above the first line of a folded sequence of lines - (void)hasFolding(curwin->w_cursor.lnum, - &curwin->w_cursor.lnum, NULL); - else - // Open below the last line of a folded sequence of lines - (void)hasFolding(curwin->w_cursor.lnum, - NULL, &curwin->w_cursor.lnum); -#endif - if (u_save((linenr_T)(curwin->w_cursor.lnum - - (cap->cmdchar == 'O' ? 1 : 0)), - (linenr_T)(curwin->w_cursor.lnum + - (cap->cmdchar == 'o' ? 1 : 0)) - ) == OK - && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, - has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, - 0, NULL) == OK) - { + if (cap->cmdchar == 'O') + // Open above the first line of a folded sequence of lines + (void)hasFolding(curwin->w_cursor.lnum, + &curwin->w_cursor.lnum, NULL); + else + // Open below the last line of a folded sequence of lines + (void)hasFolding(curwin->w_cursor.lnum, + NULL, &curwin->w_cursor.lnum); +#endif + if (u_save((linenr_T)(curwin->w_cursor.lnum - + (cap->cmdchar == 'O' ? 1 : 0)), + (linenr_T)(curwin->w_cursor.lnum + + (cap->cmdchar == 'o' ? 1 : 0)) + ) == OK + && open_line(cap->cmdchar == 'O' ? BACKWARD : FORWARD, + has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM : 0, + 0, NULL) == OK) + { #ifdef FEAT_CONCEAL - if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) - redrawWinline(curwin, oldline); + if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum) + redrawWinline(curwin, oldline); #endif #ifdef FEAT_SYN_HL - if (curwin->w_p_cul) - // force redraw of cursorline - curwin->w_valid &= ~VALID_CROW; -#endif - // When '#' is in 'cpoptions' ignore the count. - if (vim_strchr(p_cpo, CPO_HASH) != NULL) - cap->count1 = 1; - invoke_edit(cap, FALSE, cap->cmdchar, TRUE); - } + if (curwin->w_p_cul) + // force redraw of cursorline + curwin->w_valid &= ~VALID_CROW; +#endif + // When '#' is in 'cpoptions' ignore the count. + if (vim_strchr(p_cpo, CPO_HASH) != NULL) + cap->count1 = 1; + invoke_edit(cap, FALSE, cap->cmdchar, TRUE); } } @@ -6281,14 +6286,14 @@ n_opencmd(cmdarg_T *cap) static void nv_dot(cmdarg_T *cap) { - if (!checkclearopq(cap->oap)) - { - // If "restart_edit" is TRUE, the last but one command is repeated - // instead of the last command (inserting text). This is used for - // CTRL-O <.> in insert mode. - if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) - clearopbeep(cap->oap); - } + if (checkclearopq(cap->oap)) + return; + + // If "restart_edit" is TRUE, the last but one command is repeated + // instead of the last command (inserting text). This is used for + // CTRL-O <.> in insert mode. + if (start_redo(cap->count0, restart_edit != 0 && !arrow_used) == FAIL) + clearopbeep(cap->oap); } /* @@ -6316,11 +6321,11 @@ nv_redo_or_register(cmdarg_T *cap) return; } - if (!checkclearopq(cap->oap)) - { - u_redo((int)cap->count1); - curwin->w_set_curswant = TRUE; - } + if (checkclearopq(cap->oap)) + return; + + u_redo((int)cap->count1); + curwin->w_set_curswant = TRUE; } /* @@ -6336,12 +6341,14 @@ nv_Undo(cmdarg_T *cap) cap->cmdchar = 'g'; cap->nchar = 'U'; nv_operator(cap); + return; } - else if (!checkclearopq(cap->oap)) - { - u_undoline(); - curwin->w_set_curswant = TRUE; - } + + if (checkclearopq(cap->oap)) + return; + + u_undoline(); + curwin->w_set_curswant = TRUE; } /* @@ -7146,25 +7153,27 @@ nv_record(cmdarg_T *cap) cap->cmdchar = 'g'; cap->nchar = 'q'; nv_operator(cap); + return; } - else if (!checkclearop(cap->oap)) + + if (checkclearop(cap->oap)) + return; + + if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') { - if (cap->nchar == ':' || cap->nchar == '/' || cap->nchar == '?') + if (cmdwin_type != 0) { - if (cmdwin_type != 0) - { - emsg(_(e_cmdline_window_already_open)); - return; - } - stuffcharReadbuff(cap->nchar); - stuffcharReadbuff(K_CMDWIN); + emsg(_(e_cmdline_window_already_open)); + return; } - else - // (stop) recording into a named register, unless executing a - // register - if (reg_executing == 0 && do_record(cap->nchar) == FAIL) - clearopbeep(cap->oap); + stuffcharReadbuff(cap->nchar); + stuffcharReadbuff(K_CMDWIN); } + else + // (stop) recording into a named register, unless executing a + // register + if (reg_executing == 0 && do_record(cap->nchar) == FAIL) + clearopbeep(cap->oap); } /* @@ -7214,28 +7223,32 @@ nv_halfpage(cmdarg_T *cap) nv_join(cmdarg_T *cap) { if (VIsual_active) // join the visual lines + { nv_operator(cap); - else if (!checkclearop(cap->oap)) + return; + } + + if (checkclearop(cap->oap)) + return; + + if (cap->count0 <= 1) + cap->count0 = 2; // default for join is two lines! + if (curwin->w_cursor.lnum + cap->count0 - 1 > + curbuf->b_ml.ml_line_count) { - if (cap->count0 <= 1) - cap->count0 = 2; // default for join is two lines! - if (curwin->w_cursor.lnum + cap->count0 - 1 > - curbuf->b_ml.ml_line_count) + // can't join when on the last line + if (cap->count0 <= 2) { - // can't join when on the last line - if (cap->count0 <= 2) - { - clearopbeep(cap->oap); - return; - } - cap->count0 = curbuf->b_ml.ml_line_count - - curwin->w_cursor.lnum + 1; + clearopbeep(cap->oap); + return; } - - prep_redo(cap->oap->regname, cap->count0, - NUL, cap->cmdchar, NUL, NUL, cap->nchar); - (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); + cap->count0 = curbuf->b_ml.ml_line_count + - curwin->w_cursor.lnum + 1; } + + prep_redo(cap->oap->regname, cap->count0, + NUL, cap->cmdchar, NUL, NUL, cap->nchar); + (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); } /* @@ -7273,132 +7286,133 @@ nv_put_opt(cmdarg_T *cap, int fix_indent) } else #endif - clearopbeep(cap->oap); + clearopbeep(cap->oap); + return; } + #ifdef FEAT_JOB_CHANNEL - else if (bt_prompt(curbuf) && !prompt_curpos_editable()) + if (bt_prompt(curbuf) && !prompt_curpos_editable()) { clearopbeep(cap->oap); + return; } #endif - else + + if (fix_indent) { - if (fix_indent) - { - dir = (cap->cmdchar == ']' && cap->nchar == 'p') - ? FORWARD : BACKWARD; - flags |= PUT_FIXINDENT; - } - else - dir = (cap->cmdchar == 'P' - || ((cap->cmdchar == 'g' || cap->cmdchar == 'z') - && cap->nchar == 'P')) ? BACKWARD : FORWARD; - prep_redo_cmd(cap); |