diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/clint.py | 29 | ||||
| -rw-r--r-- | src/nvim/api/extmark.c | 12 | ||||
| -rw-r--r-- | src/nvim/api/vimscript.c | 4 | ||||
| -rw-r--r-- | src/nvim/buffer.c | 2 | ||||
| -rw-r--r-- | src/nvim/buffer_updates.c | 2 | ||||
| -rw-r--r-- | src/nvim/change.c | 2 | ||||
| -rw-r--r-- | src/nvim/decoration.c | 37 | ||||
| -rw-r--r-- | src/nvim/edit.c | 4 | ||||
| -rw-r--r-- | src/nvim/eval.c | 2 | ||||
| -rw-r--r-- | src/nvim/eval/userfunc.c | 2 | ||||
| -rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
| -rw-r--r-- | src/nvim/ex_docmd.c | 12 | ||||
| -rw-r--r-- | src/nvim/extmark.c | 10 | ||||
| -rw-r--r-- | src/nvim/extmark.h | 2 | ||||
| -rw-r--r-- | src/nvim/ops.c | 2 | ||||
| -rw-r--r-- | src/nvim/option.c | 2 | ||||
| -rw-r--r-- | src/nvim/screen.c | 12 | ||||
| -rw-r--r-- | src/nvim/viml/parser/expressions.c | 2 |
18 files changed, 52 insertions, 88 deletions
diff --git a/src/clint.py b/src/clint.py index cb91d9bd68..befb10c9c7 100755 --- a/src/clint.py +++ b/src/clint.py @@ -44,7 +44,6 @@ same line, but it is far from perfect (in either direction). import codecs import copy import getopt -import math # for log import os import re import sre_compile @@ -183,7 +182,6 @@ _ERROR_CATEGORIES = [ 'readability/alt_tokens', 'readability/bool', 'readability/braces', - 'readability/fn_size', 'readability/multiline_comment', 'readability/multiline_string', 'readability/nul', @@ -642,32 +640,6 @@ class _FunctionState: if self.in_a_function: self.lines_in_function += 1 - def Check(self, error, filename, linenum): - """Report if too many lines in function body. - - Args: - error: The function to call with any errors found. - filename: The name of the current file. - linenum: The number of the line to check. - """ - if Match(r'T(EST|est)', self.current_function): - base_trigger = self._TEST_TRIGGER - else: - base_trigger = self._NORMAL_TRIGGER - trigger = base_trigger * 2**_VerboseLevel() - - if self.lines_in_function > trigger: - error_level = int( - math.log(self.lines_in_function / base_trigger, 2)) - # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ... - if error_level > 5: - error_level = 5 - error(filename, linenum, 'readability/fn_size', error_level, - 'Small and focused functions are preferred:' - ' %s has %d non-comment lines' - ' (error triggered by exceeding %d lines).' % ( - self.current_function, self.lines_in_function, trigger)) - def End(self): """Stop analyzing function body.""" self.in_a_function = False @@ -1887,7 +1859,6 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, error(filename, linenum, 'readability/fn_size', 5, 'Lint failed to find start of function body.') elif Match(r'^\}\s*$', line): # function end - function_state.Check(error, filename, linenum) function_state.End() elif not Match(r'^\s*$', line): function_state.Count() # Count non-blank/non-comment lines. diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index 12b5ea2e97..e05d80812d 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -488,6 +488,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer FUNC_API_SINCE(7) { Decoration decor = DECORATION_INIT; + bool has_decor = false; buf_T *buf = find_buffer_by_handle(buffer, err); if (!buf) { @@ -577,6 +578,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer if (ERROR_SET(err)) { goto error; } + has_decor = true; } } @@ -586,6 +588,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer if (c.size) { decor.conceal_char = utf_ptr2char(c.data); } + has_decor = true; } else if (HAS_KEY(opts->conceal)) { api_set_error(err, kErrorTypeValidation, "conceal is not a String"); goto error; @@ -594,6 +597,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer if (opts->virt_text.type == kObjectTypeArray) { decor.virt_text = parse_virt_text(opts->virt_text.data.array, err, &decor.virt_text_width); + has_decor = true; if (ERROR_SET(err)) { goto error; } @@ -665,6 +669,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer if (ERROR_SET(err)) { goto error; } + has_decor = true; } } else if (HAS_KEY(opts->virt_lines)) { api_set_error(err, kErrorTypeValidation, "virt_lines is not an Array"); @@ -693,6 +698,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer api_set_error(err, kErrorTypeValidation, "sign_text is not a valid value"); goto error; } + has_decor = true; } else if (HAS_KEY(opts->sign_text)) { api_set_error(err, kErrorTypeValidation, "sign_text is not a String"); goto error; @@ -718,6 +724,9 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer OPTION_TO_BOOL(ephemeral, ephemeral, false); OPTION_TO_BOOL(decor.ui_watched, ui_watched, false); + if (decor.ui_watched) { + has_decor = true; + } if (line < 0) { api_set_error(err, kErrorTypeValidation, "line value outside range"); @@ -780,7 +789,8 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer } extmark_set(buf, (uint32_t)ns_id, &id, (int)line, (colnr_T)col, line2, col2, - &decor, right_gravity, end_right_gravity, kExtmarkNoUndo); + has_decor ? &decor : NULL, right_gravity, end_right_gravity, + kExtmarkNoUndo); } return (Integer)id; diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index d3675a3c40..9396435466 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -752,7 +752,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, E /// no range was specified, one element if only a single range item was /// specified and two elements if both range items were specified. /// - count: (number) Any |<count>| that was supplied to the command. -1 if command cannot -/// take a count. Mutually exclusive with "range". +/// take a count. /// - reg: (number) The optional command |<register>|, if specified. Empty string if not /// specified or if command cannot take a register. /// - bang: (boolean) Whether command contains a |<bang>| (!) modifier. @@ -853,7 +853,7 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err) PUT(result, "cmd", CSTR_TO_OBJ((char *)get_command_name(NULL, ea.cmdidx))); } - if ((ea.argt & EX_RANGE) && !(ea.argt & EX_COUNT) && ea.addr_count > 0) { + if ((ea.argt & EX_RANGE) && ea.addr_count > 0) { Array range = ARRAY_DICT_INIT; if (ea.addr_count > 1) { ADD(range, INTEGER_OBJ(ea.line1)); diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 2e30f7f8ec..9839f499eb 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -4544,7 +4544,7 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use } return width; -} // NOLINT(readability/fn_size) +} /// Get relative cursor position in window into "buf[buflen]", in the form 99%, /// using "Top", "Bot" or "All" when appropriate. diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index 49e3a03dac..3e2d04b3a2 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -299,7 +299,7 @@ void buf_updates_send_changes(buf_T *buf, linenr_T firstline, int64_t num_added, kv_size(buf->update_callbacks) = j; } -void buf_updates_send_splice(buf_T *buf, linenr_T start_row, colnr_T start_col, bcount_t start_byte, +void buf_updates_send_splice(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte, int old_row, colnr_T old_col, bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte) { diff --git a/src/nvim/change.c b/src/nvim/change.c index 1ddb83db0b..bbb10d3a52 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1802,7 +1802,7 @@ theend: xfree(next_line); xfree(allocated); return retval; -} // NOLINT(readability/fn_size) +} /// Delete from cursor to end of line. /// Caller must have prepared for undo. diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index c48cf6e832..28257dd7b5 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -74,8 +74,7 @@ void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor) } } - if (decor && (kv_size(decor->virt_text) - || decor->ui_watched)) { + if (decor && decor_virt_pos(*decor)) { redraw_buf_line_later(buf, row1 + 1); } @@ -175,6 +174,12 @@ Decoration get_decor(mtkey_t mark) } } +/// @return true if decor has a virtual position (virtual text or ui_watched) +static bool decor_virt_pos(Decoration decor) +{ + return kv_size(decor.virt_text) || decor.ui_watched; +} + bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state) { @@ -196,22 +201,11 @@ bool decor_redraw_start(buf_T *buf, int top_row, DecorState *state) Decoration decor = get_decor(mark); - // Exclude non-paired marks unless they contain virt_text or a sign - // or they are ui-watched - if (!mt_paired(mark) - && !kv_size(decor.virt_text) - && !decor_has_sign(&decor) - && !decor.ui_watched) { - goto next_mark; - } - mtpos_t altpos = marktree_get_altpos(buf->b_marktree, mark, NULL); // Exclude start marks if the end mark position is above the top row // Exclude end marks if we have already added the start mark - if ((mt_start(mark) && altpos.row < top_row - && !kv_size(decor.virt_text) - && !decor.ui_watched) + if ((mt_start(mark) && altpos.row < top_row && !decor_virt_pos(decor)) || (mt_end(mark) && altpos.row >= top_row)) { goto next_mark; } @@ -301,13 +295,6 @@ int decor_redraw_col(buf_T *buf, int col, int win_col, bool hidden, DecorState * endpos = mark.pos; } - if (endpos.row < mark.pos.row - || (endpos.row == mark.pos.row && endpos.col <= mark.pos.col)) { - if (!kv_size(decor.virt_text) && !decor.ui_watched) { - goto next_mark; - } - } - decor_add(state, mark.pos.row, mark.pos.col, endpos.row, endpos.col, &decor, false, mark.ns, mark.id); @@ -326,8 +313,7 @@ next_mark: bool active = false, keep = true; if (item.end_row < state->row || (item.end_row == state->row && item.end_col <= col)) { - if (!(item.start_row >= state->row - && (kv_size(item.decor.virt_text) || item.decor.ui_watched))) { + if (!(item.start_row >= state->row && decor_virt_pos(item.decor))) { keep = false; } } else { @@ -355,7 +341,7 @@ next_mark: } } if ((item.start_row == state->row && item.start_col <= col) - && (kv_size(item.decor.virt_text) || item.decor.ui_watched) + && decor_virt_pos(item.decor) && item.decor.virt_text_pos == kVTOverlay && item.win_col == -1) { item.win_col = (item.decor.virt_text_hide && hidden) ? -2 : win_col; } @@ -523,8 +509,7 @@ bool decor_redraw_eol(buf_T *buf, DecorState *state, int *eol_attr, int eol_col) bool has_virttext = false; for (size_t i = 0; i < kv_size(state->active); i++) { DecorRange item = kv_A(state->active, i); - if (item.start_row == state->row - && (kv_size(item.decor.virt_text) || item.decor.ui_watched)) { + if (item.start_row == state->row && decor_virt_pos(item.decor)) { has_virttext = true; } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 950270c14a..3821cd3f41 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2002,7 +2002,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang // TODO(bfredl): test for crazy edge cases, like we stand on a TAB or // something? does this even do the right text change then? int delta = orig_col - new_col; - extmark_splice_cols(curbuf, curwin->w_cursor.lnum - 1, new_col, + extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, new_col, delta < 0 ? -delta : 0, delta > 0 ? delta : 0, kExtmarkUndo); @@ -9117,7 +9117,7 @@ static bool ins_tab(void) } } if (!(State & VREPLACE_FLAG)) { - extmark_splice_cols(curbuf, fpos.lnum - 1, change_col, + extmark_splice_cols(curbuf, (int)fpos.lnum - 1, change_col, cursor->col - change_col, fpos.col - change_col, kExtmarkUndo); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c79afe41ed..901976bb16 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6632,7 +6632,7 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const // input() with a third argument: completion const int xp_namelen = (int)strlen(xp_name); - uint32_t argt; + uint32_t argt = 0; if (parse_compl_arg(xp_name, xp_namelen, &xp_type, &argt, &xp_arg) == FAIL) { return; diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 2dd022630a..c518b11a65 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2586,7 +2586,7 @@ ret_free: if (show_block) { ui_ext_cmdline_block_leave(); } -} // NOLINT(readability/fn_size) +} /// @return 5 if "p" starts with "<SID>" or "<SNR>" (ignoring case). /// 2 if "p" starts with "s:". diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 454c996e82..7aab27577a 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4467,7 +4467,7 @@ skip: return preview_buf; #undef ADJUST_SUB_FIRSTLNUM #undef PUSH_PREVIEW_LINES -} // NOLINT(readability/fn_size) +} /// Give message for number of substitutions. /// Can also be used after a ":global" command. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 08b7ffe00d..eed2a38a4f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1320,7 +1320,7 @@ static void parse_register(exarg_T *eap) } } -static int parse_count(exarg_T *eap, char **errormsg) +static int parse_count(exarg_T *eap, char **errormsg, bool validate) { // Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a // count, it's a buffer name. @@ -1348,7 +1348,7 @@ static int parse_count(exarg_T *eap, char **errormsg) eap->line2 += n - 1; eap->addr_count++; // Be vi compatible: no error message for out of range. - if (eap->line2 > curbuf->b_ml.ml_line_count) { + if (validate && eap->line2 > curbuf->b_ml.ml_line_count) { eap->line2 = curbuf->b_ml.ml_line_count; } } @@ -1426,7 +1426,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er } p = find_command(eap, NULL); - // Set command attribute type and parse command range + // Set command address type and parse command range set_cmd_addr_type(eap, (char_u *)p); eap->cmd = cmd; if (parse_cmd_address(eap, errormsg, false) == FAIL) { @@ -1499,7 +1499,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er // Parse register and count parse_register(eap); - if (parse_count(eap, errormsg) == FAIL) { + if (parse_count(eap, errormsg, false) == FAIL) { return false; } @@ -1981,7 +1981,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter // Parse register and count parse_register(&ea); - if (parse_count(&ea, &errormsg) == FAIL) { + if (parse_count(&ea, &errormsg, true) == FAIL) { goto doend; } @@ -2219,7 +2219,7 @@ doend: --ex_nesting_level; return ea.nextcmd; -} // NOLINT(readability/fn_size) +} static char ex_error_buf[MSG_BUF_LEN]; diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 09ea2be4fe..f367bc66e0 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -417,7 +417,7 @@ static void u_extmark_set(buf_T *buf, uint64_t mark, int row, colnr_T col) /// /// useful when we cannot simply reverse the operation. This will do nothing on /// redo, enforces correct position when undo. -void u_extmark_copy(buf_T *buf, linenr_T l_row, colnr_T l_col, linenr_T u_row, colnr_T u_col) +void u_extmark_copy(buf_T *buf, int l_row, colnr_T l_col, int u_row, colnr_T u_col) { u_header_T *uhp = u_force_get_undo_header(buf); if (!uhp) { @@ -553,7 +553,7 @@ void extmark_adjust(buf_T *buf, linenr_T line1, linenr_T line2, long amount, lon // the end column of the new region. // @param new_byte Byte extent of the new region. // @param undo -void extmark_splice(buf_T *buf, linenr_T start_row, colnr_T start_col, int old_row, colnr_T old_col, +void extmark_splice(buf_T *buf, int start_row, colnr_T start_col, int old_row, colnr_T old_col, bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte, ExtmarkOp undo) { @@ -573,7 +573,7 @@ void extmark_splice(buf_T *buf, linenr_T start_row, colnr_T start_col, int old_r undo); } -void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcount_t start_byte, +void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t start_byte, int old_row, colnr_T old_col, bcount_t old_byte, int new_row, colnr_T new_col, bcount_t new_byte, ExtmarkOp undo) { @@ -588,7 +588,7 @@ void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcou // beginning and right-gravity at the end need not be preserved. // Also be smart about marks that already have been saved (important for // merge!) - linenr_T end_row = start_row + old_row; + int end_row = start_row + old_row; int end_col = (old_row ? 0 : start_col) + old_col; u_extmark_copy(buf, start_row, start_col, end_row, end_col); } @@ -656,7 +656,7 @@ void extmark_splice_impl(buf_T *buf, linenr_T start_row, colnr_T start_col, bcou } } -void extmark_splice_cols(buf_T *buf, linenr_T start_row, colnr_T start_col, colnr_T old_col, +void extmark_splice_cols(buf_T *buf, int start_row, colnr_T start_col, colnr_T old_col, colnr_T new_col, ExtmarkOp undo) { extmark_splice(buf, start_row, start_col, diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h index 84d1e8d03b..b856a1148f 100644 --- a/src/nvim/extmark.h +++ b/src/nvim/extmark.h @@ -29,7 +29,7 @@ typedef ptrdiff_t bcount_t; // delete the columns between mincol and endcol typedef struct { - linenr_T start_row; + int start_row; colnr_T start_col; int old_row; colnr_T old_col; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index d3bae42a69..d9844b4e99 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3761,7 +3761,7 @@ end: // If the cursor is past the end of the line put it at the end. adjust_cursor_eol(); -} // NOLINT(readability/fn_size) +} /* * When the cursor is on the NUL past the end of the line and it should not be diff --git a/src/nvim/option.c b/src/nvim/option.c index ec2a6dc1ea..aac05eba0b 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3382,7 +3382,7 @@ ambw_end: check_redraw(options[opt_idx].flags); return errmsg; -} // NOLINT(readability/fn_size) +} /// Simple int comparison function for use with qsort() static int int_cmp(const void *a, const void *b) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 1e09c01173..f3e627cc65 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1704,12 +1704,10 @@ static void win_update(win_T *wp, DecorProviders *providers) wp->w_old_botfill = wp->w_botfill; // Send win_extmarks if needed - if (kv_size(win_extmark_arr) > 0) { - for (size_t n = 0; n < kv_size(win_extmark_arr); n++) { - ui_call_win_extmark(wp->w_grid_alloc.handle, wp->handle, - kv_A(win_extmark_arr, n).ns_id, kv_A(win_extmark_arr, n).mark_id, - kv_A(win_extmark_arr, n).win_row, kv_A(win_extmark_arr, n).win_col); - } + for (size_t n = 0; n < kv_size(win_extmark_arr); n++) { + ui_call_win_extmark(wp->w_grid_alloc.handle, wp->handle, + kv_A(win_extmark_arr, n).ns_id, kv_A(win_extmark_arr, n).mark_id, + kv_A(win_extmark_arr, n).win_row, kv_A(win_extmark_arr, n).win_col); } if (dollar_vcol == -1) { @@ -1748,7 +1746,7 @@ static void win_update(win_T *wp, DecorProviders *providers) if (!got_int) { got_int = save_got_int; } -} // NOLINT(readability/fn_size) +} /// Returns width of the signcolumn that should be used for the whole window /// diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 01fc282891..2693093f4a 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -3067,7 +3067,7 @@ viml_pexpr_parse_end: } kvi_destroy(ast_stack); return ast; -} // NOLINT(readability/fn_size) +} #undef NEW_NODE #undef HL |