diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/normal.c | 106 | ||||
-rw-r--r-- | src/nvim/ops.c | 74 | ||||
-rw-r--r-- | src/nvim/option.c | 54 |
3 files changed, 113 insertions, 121 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 686071e25a..438ddd6fd3 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -414,14 +414,14 @@ static int find_command(int cmdchar) return -1; } - /* We use the absolute value of the character. Special keys have a - * negative value, but are sorted on their absolute value. */ + // We use the absolute value of the character. Special keys have a + // negative value, but are sorted on their absolute value. if (cmdchar < 0) { cmdchar = -cmdchar; } - /* If the character is in the first part: The character is the index into - * nv_cmd_idx[]. */ + // If the character is in the first part: The character is the index into + // nv_cmd_idx[]. assert(nv_max_linear < (int)NV_CMDS_SIZE); if (cmdchar <= nv_max_linear) { return nv_cmd_idx[cmdchar]; @@ -3897,8 +3897,8 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_ pat = xmalloc(len + 7); - /* Put "\V" before the pattern to avoid that the special meaning of "." - * and "~" causes trouble. */ + // Put "\V" before the pattern to avoid that the special meaning of "." + // and "~" causes trouble. assert(len <= INT_MAX); sprintf((char *)pat, vim_iswordp(ptr) ? "\\V\\<%.*s\\>" : "\\V%.*s", (int)len, ptr); @@ -4252,9 +4252,9 @@ void scroll_redraw(int up, long count) check_cursor_moved(curwin); curwin->w_valid |= VALID_TOPLINE; - /* If moved back to where we were, at least move the cursor, otherwise - * we get stuck at one position. Don't move the cursor up if the - * first line of the buffer is already on the screen */ + // If moved back to where we were, at least move the cursor, otherwise + // we get stuck at one position. Don't move the cursor up if the + // first line of the buffer is already on the screen while (curwin->w_topline == prev_topline && curwin->w_topfill == prev_topfill) { if (up) { @@ -4338,7 +4338,7 @@ static void nv_zet(cmdarg_T *cap) dozet: // "zf" and "zF" are always an operator, "zd", "zo", "zO", "zc" // and "zC" only in Visual mode. "zj" and "zk" are motion - // commands. */ + // commands. if (cap->nchar != 'f' && cap->nchar != 'F' && !(VIsual_active && vim_strchr((char_u *)"dcCoO", cap->nchar)) && cap->nchar != 'j' && cap->nchar != 'k' @@ -5003,9 +5003,9 @@ static void nv_ident(cmdarg_T *cap) return; } - /* Allocate buffer to put the command in. Inserting backslashes can - * double the length of the word. p_kp / curbuf->b_p_kp could be added - * and some numbers. */ + // Allocate buffer to put the command in. Inserting backslashes can + // double the length of the word. p_kp / curbuf->b_p_kp could be added + // and some numbers. char_u *kp = *curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp; // 'keywordprg' assert(*kp != NUL); // option.c:do_set() should default to ":help" if empty. bool kp_ex = (*kp == ':'); // 'keywordprg' is an ex command @@ -5046,8 +5046,8 @@ static void nv_ident(cmdarg_T *cap) STRCAT(buf, kp); STRCAT(buf, " "); } else { - /* An external command will probably use an argument starting - * with "-" as an option. To avoid trouble we skip the "-". */ + // An external command will probably use an argument starting + // with "-" as an option. To avoid trouble we skip the "-". while (*ptr == '-' && n > 0) { ++ptr; --n; @@ -5058,8 +5058,8 @@ static void nv_ident(cmdarg_T *cap) return; } - /* When a count is given, turn it into a range. Is this - * really what we want? */ + // When a count is given, turn it into a range. Is this + // really what we want? bool isman = (STRCMP(kp, "man") == 0); bool isman_s = (STRCMP(kp, "man -s") == 0); if (cap->count0 != 0 && !(isman || isman_s)) { @@ -5141,8 +5141,8 @@ static void nv_ident(cmdarg_T *cap) if (vim_strchr(aux_ptr, *ptr) != NULL) { *p++ = '\\'; } - /* When current byte is a part of multibyte character, copy all - * bytes of that character. */ + // When current byte is a part of multibyte character, copy all + // bytes of that character. const size_t len = (size_t)(utfc_ptr2len(ptr) - 1); for (size_t i = 0; i < len && n > 0; i++, n--) { *p++ = *ptr++; @@ -5415,10 +5415,9 @@ static void nv_left(cmdarg_T *cap) cap->oap->inclusive = false; for (n = cap->count1; n > 0; --n) { if (oneleft() == false) { - /* <BS> and <Del> wrap to previous line if 'whichwrap' has 'b'. - * 'h' wraps to previous line if 'whichwrap' has 'h'. - * CURS_LEFT wraps to previous line if 'whichwrap' has '<'. - */ + // <BS> and <Del> wrap to previous line if 'whichwrap' has 'b'. + // 'h' wraps to previous line if 'whichwrap' has 'h'. + // CURS_LEFT wraps to previous line if 'whichwrap' has '<'. if ((((cap->cmdchar == K_BS || cap->cmdchar == Ctrl_H) && vim_strchr(p_ww, 'b') != NULL) || (cap->cmdchar == 'h' && vim_strchr(p_ww, 'h') != NULL) @@ -5570,9 +5569,9 @@ static void nv_dollar(cmdarg_T *cap) { cap->oap->motion_type = kMTCharWise; cap->oap->inclusive = true; - /* In virtual mode when off the edge of a line and an operator - * is pending (whew!) keep the cursor where it is. - * Otherwise, send it to the end of the line. */ + // In virtual mode when off the edge of a line and an operator + // is pending (whew!) keep the cursor where it is. + // Otherwise, send it to the end of the line. if (!virtual_active() || gchar_cursor() != NUL || cap->oap->op_type == OP_NOP) { curwin->w_curswant = MAXCOL; // so we stay at the end @@ -6278,9 +6277,9 @@ static void nv_replace(cmdarg_T *cap) ins_char(cap->ncharC2); } } - --curwin->w_cursor.col; // cursor on the last replaced char - /* if the character on the left of the current cursor is a multi-byte - * character, move two characters left */ + curwin->w_cursor.col--; // cursor on the last replaced char + // if the character on the left of the current cursor is a multi-byte + // character, move two characters left mb_adjust_cursor(); curbuf->b_op_end = curwin->w_cursor; curwin->w_set_curswant = true; @@ -6802,8 +6801,8 @@ static void n_start_visual_mode(int c) if (p_smd && msg_silent == 0) { redraw_cmdline = true; // show visual mode later } - /* Only need to redraw this line, unless still need to redraw an old - * Visual area (when 'lazyredraw' is set). */ + // Only need to redraw this line, unless still need to redraw an old + // Visual area (when 'lazyredraw' is set). if (curwin->w_redr_type < INVERTED) { curwin->w_old_cursor_lnum = curwin->w_cursor.lnum; curwin->w_old_visual_lnum = curwin->w_cursor.lnum; @@ -7571,8 +7570,8 @@ static void nv_home(cmdarg_T *cap) cap->count0 = 1; nv_pipe(cap); } - ins_at_eol = false; /* Don't move cursor past eol (only necessary in a - one-character line). */ + ins_at_eol = false; // Don't move cursor past eol (only necessary in a + // one-character line). } /* @@ -7589,8 +7588,8 @@ static void nv_pipe(cmdarg_T *cap) } else { curwin->w_curswant = 0; } - /* keep curswant at the column where we wanted to go, not where - * we ended; differs if line is too short */ + // keep curswant at the column where we wanted to go, not where + // we ended; differs if line is too short curwin->w_set_curswant = false; } @@ -7661,8 +7660,8 @@ static void nv_wordcmd(cmdarg_T *cap) n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP); } - /* Don't leave the cursor on the NUL past the end of line. Unless we - * didn't move it forward. */ + // Don't leave the cursor on the NUL past the end of line. Unless we + // didn't move it forward. if (lt(startpos, curwin->w_cursor)) { adjust_cursor(cap->oap); } @@ -7711,8 +7710,8 @@ static void nv_beginline(cmdarg_T *cap) if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) { foldOpenCursor(); } - ins_at_eol = false; /* Don't move cursor past eol (only necessary in a - one-character line). */ + ins_at_eol = false; // Don't move cursor past eol (only necessary in a + // one-character line). } /* @@ -7857,8 +7856,8 @@ static void nv_esc(cmdarg_T *cap) } } - /* Don't reset "restart_edit" when 'insertmode' is set, it won't be - * set again below when halfway through a mapping. */ + // Don't reset "restart_edit" when 'insertmode' is set, it won't be + // set again below when halfway through a mapping. if (!p_im) { restart_edit = 0; } @@ -7885,8 +7884,8 @@ static void nv_esc(cmdarg_T *cap) } clearop(cap->oap); - /* A CTRL-C is often used at the start of a menu. When 'insertmode' is - * set return to Insert mode afterwards. */ + // A CTRL-C is often used at the start of a menu. When 'insertmode' is + // set return to Insert mode afterwards. if (restart_edit == 0 && goto_im() && ex_normal_busy == 0) { restart_edit = 'a'; @@ -7940,8 +7939,8 @@ static void nv_edit(cmdarg_T *cap) break; case 'a': // "a"ppend is like "i"nsert on the next character. - /* increment coladd when in virtual space, increment the - * column otherwise, also to append after an unprintable char */ + // increment coladd when in virtual space, increment the + // column otherwise, also to append after an unprintable char if (virtual_active() && (curwin->w_cursor.coladd > 0 || *get_cursor_pos_ptr() == NUL @@ -8209,11 +8208,10 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) } if (VIsual_active) { - /* Putting in Visual mode: The put text replaces the selected - * text. First delete the selected text, then put the new text. - * Need to save and restore the registers that the delete - * overwrites if the old contents is being put. - */ + // Putting in Visual mode: The put text replaces the selected + // text. First delete the selected text, then put the new text. + // Need to save and restore the registers that the delete + // overwrites if the old contents is being put. was_visual = true; regname = cap->oap->regname; // '+' and '*' could be the same selection @@ -8286,14 +8284,14 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) } } - /* When all lines were selected and deleted do_put() leaves an empty - * line that needs to be deleted now. */ + // When all lines were selected and deleted do_put() leaves an empty + // line that needs to be deleted now. if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) { ml_delete(curbuf->b_ml.ml_line_count, true); deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); - /* If the cursor was in that line, move it to the end of the last - * line. */ + // If the cursor was in that line, move it to the end of the last + // line. if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; coladvance(MAXCOL); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 3a8f7c42a5..eb37213f1a 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -391,8 +391,8 @@ static void shift_block(oparg_T *oap, int amount) total += incr; bd.start_vcol += incr; } - /* OK, now total=all the VWS reqd, and textstart points at the 1st - * non-ws char in the block. */ + // OK, now total=all the VWS reqd, and textstart points at the 1st + // non-ws char in the block. if (!curbuf->b_p_et) { tabstop_fromto(ws_vcol, ws_vcol + total, p_ts, p_vts, &i, &j); } else { @@ -459,14 +459,14 @@ static void shift_block(oparg_T *oap, int amount) // The column to which we will shift the text. destination_col = non_white_col - shift_amount; - /* Now let's find out how much of the beginning of the line we can - * reuse without modification. */ + // Now let's find out how much of the beginning of the line we can + // reuse without modification. verbatim_copy_end = bd.textstart; verbatim_copy_width = bd.start_vcol; - /* If "bd.startspaces" is set, "bd.textstart" points to the character - * preceding the block. We have to subtract its width to obtain its - * column number. */ + // If "bd.startspaces" is set, "bd.textstart" points to the character + // preceding the block. We have to subtract its width to obtain its + // column number. if (bd.startspaces) { verbatim_copy_width -= bd.start_char_vcols; } @@ -482,9 +482,9 @@ static void shift_block(oparg_T *oap, int amount) MB_PTR_ADV(verbatim_copy_end); } - /* If "destination_col" is different from the width of the initial - * part of the line that will be copied, it means we encountered a tab - * character, which we will have to partly replace with spaces. */ + // If "destination_col" is different from the width of the initial + // part of the line that will be copied, it means we encountered a tab + // character, which we will have to partly replace with spaces. assert(destination_col - verbatim_copy_width >= 0); fill = (size_t)(destination_col - verbatim_copy_width); @@ -1500,8 +1500,8 @@ int op_delete(oparg_T *oap) did_yank = true; } - /* Yank into small delete register when no named register specified - * and the delete is within one line. */ + // Yank into small delete register when no named register specified + // and the delete is within one line. if (oap->regname == 0 && oap->motion_type != kMTLineWise && oap->line_count == 1) { reg = get_yank_register('-', YREG_YANK); @@ -1659,9 +1659,8 @@ int op_delete(oparg_T *oap) n = oap->end.col - oap->start.col + 1 - !oap->inclusive; if (virtual_op) { - /* fix up things for virtualedit-delete: - * break the tabs which are going to get in our way - */ + // fix up things for virtualedit-delete: + // break the tabs which are going to get in our way char_u *curline = get_cursor_line_ptr(); int len = (int)STRLEN(curline); @@ -1818,12 +1817,11 @@ int op_replace(oparg_T *oap, int c) continue; // nothing to replace } - /* n == number of extra chars required - * If we split a TAB, it may be replaced by several characters. - * Thus the number of characters may increase! - */ - /* If the range starts in virtual space, count the initial - * coladd offset as part of "startspaces" */ + // n == number of extra chars required + // If we split a TAB, it may be replaced by several characters. + // Thus the number of characters may increase! + // If the range starts in virtual space, count the initial + // coladd offset as part of "startspaces" if (virtual_op && bd.is_short && *bd.textstart == NUL) { pos_T vpos; @@ -2255,15 +2253,15 @@ void op_insert(oparg_T *oap, long count1) // When a tab was inserted, and the characters in front of the tab // have been converted to a tab as well, the column of the cursor - // might have actually been reduced, so need to adjust here. */ + // might have actually been reduced, so need to adjust here. if (t1.lnum == curbuf->b_op_start_orig.lnum && lt(curbuf->b_op_start_orig, t1)) { oap->start = curbuf->b_op_start_orig; } - /* If user has moved off this line, we don't know what to do, so do - * nothing. - * Also don't repeat the insert when Insert mode ended with CTRL-C. */ + // If user has moved off this line, we don't know what to do, so do + // nothing. + // Also don't repeat the insert when Insert mode ended with CTRL-C. if (curwin->w_cursor.lnum != oap->start.lnum || got_int) { return; } @@ -2440,8 +2438,8 @@ int op_change(oparg_T *oap) ins_len = (long)STRLEN(firstline) - pre_textlen; if (ins_len > 0) { - /* Subsequent calls to ml_get() flush the firstline data - take a - * copy of the inserted text. */ + // Subsequent calls to ml_get() flush the firstline data - take a + // copy of the inserted text. ins_text = (char_u *)xmalloc((size_t)(ins_len + 1)); STRLCPY(ins_text, firstline + bd.textcol, ins_len + 1); for (linenr = oap->start.lnum + 1; linenr <= oap->end.lnum; @@ -2450,8 +2448,8 @@ int op_change(oparg_T *oap) if (!bd.is_short || virtual_op) { pos_T vpos; - /* If the block starts in virtual space, count the - * initial coladd offset as part of "startspaces" */ + // If the block starts in virtual space, count the + // initial coladd offset as part of "startspaces" if (bd.is_short) { vpos.lnum = linenr; (void)getvpos(&vpos, oap->start_vcol); @@ -3834,9 +3832,8 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co *is_comment = false; if (leader_offset != -1) { - /* Let's check whether the line ends with an unclosed comment. - * If the last comment leader has COM_END in flags, there's no comment. - */ + // Let's check whether the line ends with an unclosed comment. + // If the last comment leader has COM_END in flags, there's no comment. while (*comment_flags) { if (*comment_flags == COM_END || *comment_flags == ':') { @@ -3859,11 +3856,10 @@ char_u *skip_comment(char_u *line, bool process, bool include_space, bool *is_co return line; } - /* Find: - * - COM_END, - * - colon, - * whichever comes first. - */ + // Find: + // - COM_END, + // - colon, + // whichever comes first. while (*comment_flags) { if (*comment_flags == COM_END || *comment_flags == ':') { @@ -4655,8 +4651,8 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, bool bdp->endspaces = oap->end_vcol - oap->start_vcol + 1; } } else { - /* notice: this converts partly selected Multibyte characters to - * spaces, too. */ + // notice: this converts partly selected Multibyte characters to + // spaces, too. bdp->startspaces = bdp->start_vcol - oap->start_vcol; if (is_del && bdp->startspaces) { bdp->startspaces = bdp->start_char_vcols - bdp->startspaces; diff --git a/src/nvim/option.c b/src/nvim/option.c index fb888ffd0f..05dcf737b2 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -568,12 +568,11 @@ void set_init_1(bool clean_arg) save_file_ff(curbuf); // Buffer is unchanged - /* Detect use of mlterm. - * Mlterm is a terminal emulator akin to xterm that has some special - * abilities (bidi namely). - * NOTE: mlterm's author is being asked to 'set' a variable - * instead of an environment variable due to inheritance. - */ + // Detect use of mlterm. + // Mlterm is a terminal emulator akin to xterm that has some special + // abilities (bidi namely). + // NOTE: mlterm's author is being asked to 'set' a variable + // instead of an environment variable due to inheritance. if (os_env_exists("MLTERM")) { set_option_value("tbidi", 1L, NULL, 0); } @@ -1308,16 +1307,16 @@ int do_set(char_u *arg, int opt_flags) int comma; bool new_value_alloced = false; // new string option was allocated - /* When using ":set opt=val" for a global option - * with a local value the local value will be - * reset, use the global value here. */ + // When using ":set opt=val" for a global option + // with a local value the local value will be + // reset, use the global value here. if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0 && ((int)options[opt_idx].indir & PV_BOTH)) { varp = options[opt_idx].var; } - /* The old value is kept until we are sure that the - * new value is valid. */ + // The old value is kept until we are sure that the + // new value is valid. oldval = *(char_u **)varp; // When setting the local value of a global @@ -1493,8 +1492,8 @@ int do_set(char_u *arg, int opt_flags) } } - /* locate newval[] in origval[] when removing it - * and when adding to avoid duplicates */ + // locate newval[] in origval[] when removing it + // and when adding to avoid duplicates i = 0; // init for GCC if (removing || (flags & P_NODUP)) { i = (int)STRLEN(newval); @@ -1724,9 +1723,9 @@ static void did_set_option(int opt_idx, int opt_flags, int new_value, int value_ { options[opt_idx].flags |= P_WAS_SET; - /* When an option is set in the sandbox, from a modeline or in secure mode - * set the P_INSECURE flag. Otherwise, if a new value is stored reset the - * flag. */ + // When an option is set in the sandbox, from a modeline or in secure mode + // set the P_INSECURE flag. Otherwise, if a new value is stored reset the + // flag. uint32_t *p = insecure_flag(curwin, opt_idx, opt_flags); if (!value_checked && (secure || sandbox != 0 @@ -5259,8 +5258,8 @@ int makeset(FILE *fd, int opt_flags, int local_only) } } - /* Round 1: fresh value for window-local options. - * Round 2: other values */ + // Round 1: fresh value for window-local options. + // Round 2: other values for (; round <= 2; varp = varp_local, round++) { if (round == 1 || (opt_flags & OPT_GLOBAL)) { cmd = "set"; @@ -6229,13 +6228,13 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_sua = vim_strsave(p_sua); buf->b_p_keymap = vim_strsave(p_keymap); buf->b_kmap_state |= KEYMAP_INIT; - /* This isn't really an option, but copying the langmap and IME - * state from the current buffer is better than resetting it. */ + // This isn't really an option, but copying the langmap and IME + // state from the current buffer is better than resetting it. buf->b_p_iminsert = p_iminsert; buf->b_p_imsearch = p_imsearch; - /* options that are normally global but also have a local value - * are not copied, start using the global value */ + // options that are normally global but also have a local value + // are not copied, start using the global value buf->b_p_ar = -1; buf->b_p_ul = NO_LOCAL_UNDOLEVEL; buf->b_p_bkc = empty_option; @@ -6486,8 +6485,8 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags) } } - /* For an option that is a list of file names, find the start of the - * last file name. */ + // For an option that is a list of file names, find the start of the + // last file name. for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; p--) { // count number of backslashes before ' ' or ',' if (*p == ' ' || *p == ',') { @@ -6521,10 +6520,9 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** static char *(names[]) = { "all" }; int ic = regmatch->rm_ic; // remember the ignore-case flag - /* do this loop twice: - * loop == 0: count the number of matching options - * loop == 1: copy the matching options into allocated memory - */ + // do this loop twice: + // loop == 0: count the number of matching options + // loop == 1: copy the matching options into allocated memory for (loop = 0; loop <= 1; loop++) { regmatch->rm_ic = ic; if (xp->xp_context != EXPAND_BOOL_SETTINGS) { |