From c8c930ea785aa393ebc819139913a9e05f0ccd45 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:24:46 +0100 Subject: refactor: reduce scope of locals as per the style guide (#22206) --- src/nvim/indent.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index ec6c72da6d..ee9bc48460 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -460,7 +460,6 @@ int set_indent(int size, int flags) int line_len; int doit = false; int ind_done = 0; // Measured in spaces. - int ind_col = 0; int tab_pad; int retval = false; @@ -479,6 +478,7 @@ int set_indent(int size, int flags) // 'preserveindent' are set count the number of characters at the // beginning of the line to be copied. if (!curbuf->b_p_et || (!(flags & SIN_INSERT) && curbuf->b_p_pi)) { + int ind_col = 0; // If 'preserveindent' is set then reuse as much as possible of // the existing indent structure for the new indent. if (!(flags & SIN_INSERT) && curbuf->b_p_pi) { @@ -936,14 +936,10 @@ void ex_retab(exarg_T *eap) long num_spaces = 0; long num_tabs; long len; - long col; - long vcol; long start_col = 0; // For start of white-space string long start_vcol = 0; // For start of white-space string long old_len; - char *ptr; char *new_line = (char *)1; // init to non-NULL - bool did_undo; // called u_save for current line long *new_vts_array = NULL; char *new_ts_str; // string value of tab argument @@ -972,10 +968,10 @@ void ex_retab(exarg_T *eap) new_ts_str = xstrnsave(new_ts_str, (size_t)(eap->arg - new_ts_str)); } for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) { - ptr = ml_get(lnum); - col = 0; - vcol = 0; - did_undo = false; + char *ptr = ml_get(lnum); + long col = 0; + long vcol = 0; + bool did_undo = false; // called u_save for current line for (;;) { if (ascii_iswhite(ptr[col])) { if (!got_tab && num_spaces == 0) { @@ -1186,10 +1182,6 @@ int get_lisp_indent(void) pos_T *pos, realpos, paren; int amount; char *that; - colnr_T col; - colnr_T firsttry; - int parencount; - int quotecount; int vi_lisp; // Set vi_lisp to use the vi-compatible method. @@ -1213,7 +1205,7 @@ int get_lisp_indent(void) // Extra trick: Take the indent of the first previous non-white // line that is at the same () level. amount = -1; - parencount = 0; + int parencount = 0; while (--curwin->w_cursor.lnum >= pos->lnum) { if (linewhite(curwin->w_cursor.lnum)) { @@ -1268,7 +1260,7 @@ int get_lisp_indent(void) if (amount == -1) { curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.col = pos->col; - col = pos->col; + colnr_T col = pos->col; that = get_cursor_line_ptr(); @@ -1298,7 +1290,7 @@ int get_lisp_indent(void) that++; amount++; } - firsttry = amount; + colnr_T firsttry = amount; init_chartabsize_arg(&cts, curwin, (colnr_T)(that - line), amount, line, that); @@ -1319,13 +1311,13 @@ int get_lisp_indent(void) } parencount = 0; - quotecount = 0; init_chartabsize_arg(&cts, curwin, (colnr_T)(that - line), amount, line, that); if (vi_lisp || ((*that != '"') && (*that != '\'') && (*that != '#') && (((uint8_t)(*that) < '0') || ((uint8_t)(*that) > '9')))) { + int quotecount = 0; while (*cts.cts_ptr && (!ascii_iswhite(*cts.cts_ptr) || quotecount || parencount) && (!((*cts.cts_ptr == '(' || *cts.cts_ptr == '[') @@ -1373,12 +1365,11 @@ int get_lisp_indent(void) static int lisp_match(char *p) { char buf[LSIZE]; - int len; char *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords; while (*word != NUL) { (void)copy_option_part(&word, buf, LSIZE, ","); - len = (int)strlen(buf); + int len = (int)strlen(buf); if ((strncmp(buf, p, (size_t)len) == 0) && ascii_iswhite_or_nul(p[len])) { return true; -- cgit From 98e8464319439a934946c67bbcb9c78e865a08c8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 4 Mar 2023 11:17:39 +0800 Subject: vim-patch:9.0.0016: comparing line pointer for 'breakindent' is not reliable Problem: Comparing line pointer for 'breakindent' is not reliable. Solution: Make a copy of the line. https://github.com/vim/vim/commit/c2a79b87fc31080ba24394c0b30bab45f1bea852 Test changes have been squashed into the previous commit. Co-authored-by: Bram Moolenaar --- src/nvim/indent.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index ee9bc48460..c57d26dbe0 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -803,11 +803,12 @@ bool briopt_check(win_T *wp) int get_breakindent_win(win_T *wp, char *line) FUNC_ATTR_NONNULL_ALL { - static int prev_indent = 0; // Cached indent value. - static long prev_ts = 0L; // Cached tabstop value. - static const char *prev_line = NULL; // cached pointer to line. - static varnumber_T prev_tick = 0; // Changedtick of cached value. - static long *prev_vts = NULL; // Cached vartabs values. + static int prev_indent = 0; // cached indent value + static long prev_ts = 0L; // cached tabstop value + static int prev_fnum = 0; // cached buffer number + static char *prev_line = NULL; // cached copy of "line" + static varnumber_T prev_tick = 0; // changedtick of cached value + static long *prev_vts = NULL; // cached vartabs values static int prev_list = 0; // cached list value static int prev_listopt = 0; // cached w_p_briopt_list value static char *prev_flp = NULL; // cached formatlistpat value @@ -818,16 +819,24 @@ int get_breakindent_win(win_T *wp, char *line) && (vim_strchr(p_cpo, CPO_NUMCOL) == NULL) ? number_width(wp) + 1 : 0); // used cached indent, unless - // - line pointer changed + // - buffer changed // - 'tabstop' changed + // - buffer was changed // - 'briopt_list changed' changed or // - 'formatlistpattern' changed - if (prev_line != line || prev_ts != wp->w_buffer->b_p_ts + // - line changed + // - 'vartabs' changed + if (prev_fnum != wp->w_buffer->b_fnum + || prev_ts != wp->w_buffer->b_p_ts || prev_tick != buf_get_changedtick(wp->w_buffer) || prev_listopt != wp->w_briopt_list - || (prev_flp == NULL || (strcmp(prev_flp, get_flp_value(wp->w_buffer)) != 0)) + || prev_flp == NULL + || strcmp(prev_flp, get_flp_value(wp->w_buffer)) != 0 + || prev_line == NULL || strcmp(prev_line, line) != 0 || prev_vts != wp->w_buffer->b_p_vts_array) { - prev_line = line; + prev_fnum = wp->w_buffer->b_fnum; + xfree(prev_line); + prev_line = xstrdup(line); prev_ts = wp->w_buffer->b_p_ts; prev_tick = buf_get_changedtick(wp->w_buffer); prev_vts = wp->w_buffer->b_p_vts_array; -- cgit From d6ecead36406233cc56353dd05f3380f0497630f Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 14 Mar 2023 11:49:46 +0100 Subject: refactor(screen): screen.c delenda est drawscreen.c vs screen.c makes absolutely no sense. The screen exists only to draw upon it, therefore helper functions are distributed randomly between screen.c and the file that does the redrawing. In addition screen.c does a lot of drawing on the screen. It made more sense for vim/vim as our grid.c is their screen.c Not sure if we want to dump all the code for option chars into optionstr.c, so keep these in a optionchar.c for now. --- src/nvim/indent.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index c57d26dbe0..6ad19c6f96 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -36,7 +36,6 @@ #include "nvim/plines.h" #include "nvim/pos.h" #include "nvim/regexp.h" -#include "nvim/screen.h" #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/textformat.h" -- cgit From 04933b1ea968f958d2541dd65fd33ebb503caac3 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:08:16 +0200 Subject: refactor: remove redundant casts --- src/nvim/indent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 6ad19c6f96..8a65e88545 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -427,7 +427,7 @@ int get_indent_str_vtab(const char *ptr, long ts, long *vts, bool list) } else { // In list mode, when tab is not set, count screen char width // for Tab, displays: ^I - count += ptr2cells((char *)ptr); + count += ptr2cells(ptr); } } else if (*ptr == ' ') { count++; // count a space for one -- cgit From 5d3ad6fd9031040da856167d4672154149625e8f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 17 Apr 2023 15:24:40 +0800 Subject: vim-patch:8.2.4185: cannot use an import in 'indentexpr' Problem: Cannot use an import in 'indentexpr'. Solution: Set the script context when evaluating 'indentexpr' https://github.com/vim/vim/commit/28e60cc088cadd25afb69ee636f0e2e34233ba4e Co-authored-by: Bram Moolenaar --- src/nvim/indent.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 8a65e88545..1d8bceae4e 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -1122,6 +1122,7 @@ int get_expr_indent(void) int save_set_curswant; int save_State; int use_sandbox = was_set_insecurely(curwin, "indentexpr", OPT_LOCAL); + const sctx_T save_sctx = current_sctx; // Save and restore cursor position and curswant, in case it was changed // * via :normal commands. @@ -1134,6 +1135,7 @@ int get_expr_indent(void) sandbox++; } textlock++; + current_sctx = curbuf->b_p_script_ctx[BV_INDE].script_ctx; // Need to make a copy, the 'indentexpr' option could be changed while // evaluating it. @@ -1145,6 +1147,7 @@ int get_expr_indent(void) sandbox--; } textlock--; + current_sctx = save_sctx; // Restore the cursor position so that 'indentexpr' doesn't need to. // Pretend to be in Insert mode, allow cursor past end of line for "o" -- cgit From 3b0df1780e2c8526bda5dead18ee7cc45925caba Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 26 Apr 2023 23:23:44 +0200 Subject: refactor: uncrustify Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`. --- src/nvim/indent.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 1d8bceae4e..7e12637c6d 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -527,7 +527,7 @@ int set_indent(int size, int flags) } // Count tabs required for indent. - for (;;) { + while (true) { tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts, curbuf->b_p_vts_array); if (todo < tab_pad) { break; @@ -650,7 +650,7 @@ int set_indent(int size, int flags) p = skipwhite(p); } - for (;;) { + while (true) { tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_array); @@ -980,7 +980,7 @@ void ex_retab(exarg_T *eap) long col = 0; long vcol = 0; bool did_undo = false; // called u_save for current line - for (;;) { + while (true) { if (ascii_iswhite(ptr[col])) { if (!got_tab && num_spaces == 0) { // First consecutive white-space -- cgit From cefd774fac76b91f5368833555818c80c992c3b1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 24 Aug 2023 15:14:23 +0200 Subject: refactor(memline): distinguish mutating uses of ml_get_buf() ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline. --- src/nvim/indent.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 7e12637c6d..fb6228ae2d 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -378,10 +378,7 @@ int get_indent_lnum(linenr_T lnum) // "buf". int get_indent_buf(buf_T *buf, linenr_T lnum) { - return get_indent_str_vtab(ml_get_buf(buf, lnum, false), - buf->b_p_ts, - buf->b_p_vts_array, - false); + return get_indent_str_vtab(ml_get_buf(buf, lnum), buf->b_p_ts, buf->b_p_vts_array, false); } /// Count the size (in window cells) of the indent in line "ptr", with -- cgit From 008154954791001efcc46c28146e21403f3a698b Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 21 Aug 2023 14:52:17 +0200 Subject: refactor(change): do API changes to buffer without curbuf switch Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired. --- src/nvim/indent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index fb6228ae2d..c16a94f06c 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -1083,7 +1083,7 @@ void ex_retab(exarg_T *eap) redraw_curbuf_later(UPD_NOT_VALID); } if (first_line != 0) { - changed_lines(first_line, 0, last_line + 1, 0L, true); + changed_lines(curbuf, first_line, 0, last_line + 1, 0L, true); } curwin->w_p_list = save_list; // restore 'list' @@ -1107,7 +1107,7 @@ void ex_retab(exarg_T *eap) } coladvance(curwin->w_curswant); - u_clearline(); + u_clearline(curbuf); } /// Get indent level from 'indentexpr'. -- cgit From af7d317f3ff31d5ac5d8724b5057a422e1451b54 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 26 Sep 2023 22:36:08 +0200 Subject: refactor: remove long long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform. --- src/nvim/indent.c | 57 +++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index c16a94f06c..5bd265834c 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -51,7 +51,7 @@ /// "array" will be set, caller must free it if needed. /// /// @return false for an error. -bool tabstop_set(char *var, long **array) +bool tabstop_set(char *var, colnr_T **array) { long valcount = 1; int t; @@ -87,8 +87,8 @@ bool tabstop_set(char *var, long **array) return false; } - *array = (long *)xmalloc((unsigned)(valcount + 1) * sizeof(long)); - (*array)[0] = valcount; + *array = (colnr_T *)xmalloc((unsigned)(valcount + 1) * sizeof(long)); + (*array)[0] = (colnr_T)valcount; t = 1; for (cp = var; *cp != NUL;) { @@ -115,9 +115,9 @@ bool tabstop_set(char *var, long **array) /// Calculate the number of screen spaces a tab will occupy. /// If "vts" is set then the tab widths are taken from that array, /// otherwise the value of ts is used. -int tabstop_padding(colnr_T col, long ts_arg, const long *vts) +int tabstop_padding(colnr_T col, OptInt ts_arg, const colnr_T *vts) { - long ts = ts_arg == 0 ? 8 : ts_arg; + OptInt ts = ts_arg == 0 ? 8 : ts_arg; colnr_T tabcol = 0; int t; long padding = 0; @@ -129,7 +129,7 @@ int tabstop_padding(colnr_T col, long ts_arg, const long *vts) const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > col) { padding = tabcol - col; break; @@ -143,7 +143,7 @@ int tabstop_padding(colnr_T col, long ts_arg, const long *vts) } /// Find the size of the tab that covers a particular column. -int tabstop_at(colnr_T col, long ts, const long *vts) +int tabstop_at(colnr_T col, OptInt ts, const colnr_T *vts) { colnr_T tabcol = 0; int t; @@ -155,7 +155,7 @@ int tabstop_at(colnr_T col, long ts, const long *vts) const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > col) { tab_size = vts[t]; break; @@ -169,7 +169,7 @@ int tabstop_at(colnr_T col, long ts, const long *vts) } /// Find the column on which a tab starts. -colnr_T tabstop_start(colnr_T col, long ts, long *vts) +colnr_T tabstop_start(colnr_T col, long ts, colnr_T *vts) { colnr_T tabcol = 0; int t; @@ -180,26 +180,26 @@ colnr_T tabstop_start(colnr_T col, long ts, long *vts) const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > col) { - return (int)(tabcol - vts[t]); + return (tabcol - vts[t]); } } - const int excess = (int)(tabcol % vts[tabcount]); - return (int)(excess + ((col - excess) / vts[tabcount]) * vts[tabcount]); + const int excess = (tabcol % vts[tabcount]); + return (excess + ((col - excess) / vts[tabcount]) * vts[tabcount]); } /// Find the number of tabs and spaces necessary to get from one column /// to another. -void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const long *vts, int *ntabs, +void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const colnr_T *vts, int *ntabs, int *nspcs) { int spaces = end_col - start_col; colnr_T tabcol = 0; long padding = 0; int t; - long ts = ts_arg == 0 ? curbuf->b_p_ts : ts_arg; + long ts = ts_arg == 0 ? (long)curbuf->b_p_ts : ts_arg; assert(ts != 0); // suppress clang "Division by zero" if (vts == NULL || vts[0] == 0) { @@ -221,7 +221,7 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const long // Find the padding needed to reach the next tabstop. const long tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { - tabcol += (colnr_T)vts[t]; + tabcol += vts[t]; if (tabcol > start_col) { padding = tabcol - start_col; break; @@ -257,7 +257,7 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const long } /// See if two tabstop arrays contain the same values. -bool tabstop_eq(const long *ts1, const long *ts2) +bool tabstop_eq(const colnr_T *ts1, const colnr_T *ts2) { int t; @@ -299,13 +299,13 @@ int *tabstop_copy(const long *oldts) } /// Return a count of the number of tabstops. -int tabstop_count(long *ts) +int tabstop_count(colnr_T *ts) { return ts != NULL ? (int)ts[0] : 0; } /// Return the first tabstop, or 8 if there are no tabstops defined. -int tabstop_first(long *ts) +int tabstop_first(colnr_T *ts) { return ts != NULL ? (int)ts[1] : 8; } @@ -343,7 +343,7 @@ long get_sw_value_indent(buf_T *buf) /// Idem, using virtual column "col". long get_sw_value_col(buf_T *buf, colnr_T col) { - return buf->b_p_sw ? buf->b_p_sw + return buf->b_p_sw ? (long)buf->b_p_sw : tabstop_at(col, buf->b_p_ts, buf->b_p_vts_array); } @@ -351,9 +351,8 @@ long get_sw_value_col(buf_T *buf, colnr_T col) /// using the shiftwidth value when 'softtabstop' is negative. int get_sts_value(void) { - long result = curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts; - assert(result >= 0 && result <= INT_MAX); - return (int)result; + int result = curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : (int)curbuf->b_p_sts; + return result; } // Count the size (in window cells) of the indent in the current line. @@ -413,7 +412,7 @@ int get_indent_str(const char *ptr, int ts, bool list) /// Count the size (in window cells) of the indent in line "ptr", using /// variable tabstops. /// if "list" is true, count only screen size for tabs. -int get_indent_str_vtab(const char *ptr, long ts, long *vts, bool list) +int get_indent_str_vtab(const char *ptr, OptInt ts, colnr_T *vts, bool list) { int count = 0; @@ -800,11 +799,11 @@ int get_breakindent_win(win_T *wp, char *line) FUNC_ATTR_NONNULL_ALL { static int prev_indent = 0; // cached indent value - static long prev_ts = 0L; // cached tabstop value + static OptInt prev_ts = 0L; // cached tabstop value static int prev_fnum = 0; // cached buffer number static char *prev_line = NULL; // cached copy of "line" static varnumber_T prev_tick = 0; // changedtick of cached value - static long *prev_vts = NULL; // cached vartabs values + static colnr_T *prev_vts = NULL; // cached vartabs values static int prev_list = 0; // cached list value static int prev_listopt = 0; // cached w_p_briopt_list value static char *prev_flp = NULL; // cached formatlistpat value @@ -945,7 +944,7 @@ void ex_retab(exarg_T *eap) long start_vcol = 0; // For start of white-space string long old_len; char *new_line = (char *)1; // init to non-NULL - long *new_vts_array = NULL; + colnr_T *new_vts_array = NULL; char *new_ts_str; // string value of tab argument int save_list; @@ -1000,7 +999,7 @@ void ex_retab(exarg_T *eap) int t, s; tabstop_fromto((colnr_T)start_vcol, (colnr_T)vcol, - curbuf->b_p_ts, new_vts_array, &t, &s); + (long)curbuf->b_p_ts, new_vts_array, &t, &s); num_tabs = t; num_spaces = s; } @@ -1091,7 +1090,7 @@ void ex_retab(exarg_T *eap) if (new_ts_str != NULL) { // set the new tabstop // If 'vartabstop' is in use or if the value given to retab has more // than one tabstop then update 'vartabstop'. - long *old_vts_ary = curbuf->b_p_vts_array; + colnr_T *old_vts_ary = curbuf->b_p_vts_array; if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) { set_string_option_direct("vts", -1, new_ts_str, OPT_FREE | OPT_LOCAL, 0); -- cgit From cf8b2c0e74fd5e723b0c15c2ce84e6900fd322d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 12:05:28 +0800 Subject: build(iwyu): add a few more _defs.h mappings (#25435) --- src/nvim/indent.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 5bd265834c..e01acb48b6 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include -- cgit From dc6d0d2daf69e2fdadda81feb97906dbc962a239 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 14:41:34 +0800 Subject: refactor: reorganize option header files (#25437) - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other --- src/nvim/indent.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index e01acb48b6..b7bc23cda5 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -32,6 +32,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/plines.h" -- cgit From f06af5e66981095f3244f67d1587ce7e9853eb4c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Sep 2023 08:13:58 +0800 Subject: vim-patch:9.0.1958: cannot complete option values Problem: cannot complete option values Solution: Add completion functions for several options Add cmdline tab-completion for setting string options Add tab-completion for setting string options on the cmdline using `:set=` (along with `:set+=` and `:set-=`). The existing tab completion for setting options currently only works when nothing is typed yet, and it only fills in with the existing value, e.g. when the user does `:set diffopt=` it will be completed to `set diffopt=internal,filler,closeoff` and nothing else. This isn't too useful as a user usually wants auto-complete to suggest all the possible values, such as 'iblank', or 'algorithm:patience'. For set= and set+=, this adds a new optional callback function for each option that can be invoked when doing completion. This allows for each option to have control over how completion works. For example, in 'diffopt', it will suggest the default enumeration, but if `algorithm:` is selected, it will further suggest different algorithm types like 'meyers' and 'patience'. When using set=, the existing option value will be filled in as the first choice to preserve the existing behavior. When using set+= this won't happen as it doesn't make sense. For flag list options (e.g. 'mouse' and 'guioptions'), completion will take into account existing typed values (and in the case of set+=, the existing option value) to make sure it doesn't suggest duplicates. For set-=, there is a new `ExpandSettingSubtract` function which will handle flag list and comma-separated options smartly, by only suggesting values that currently exist in the option. Note that Vim has some existing code that adds special handling for 'filetype', 'syntax', and misc dir options like 'backupdir'. This change preserves them as they already work, instead of converting to the new callback API for each option. closes: vim/vim#13182 https://github.com/vim/vim/commit/900894b09a95398dfc75599e9f0aa2ea25723384 Co-authored-by: Yee Cheng Chin --- src/nvim/indent.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index b7bc23cda5..55235e454c 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -760,6 +760,7 @@ bool briopt_check(win_T *wp) char *p = wp->w_p_briopt; while (*p != NUL) { + // Note: Keep this in sync with p_briopt_values if (strncmp(p, "shift:", 6) == 0 && ((p[6] == '-' && ascii_isdigit(p[7])) || ascii_isdigit(p[6]))) { p += 6; -- cgit From e72b546354cd90bf0cd8ee6dd045538d713009ad Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/indent.c | 88 +++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 45 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 55235e454c..d19164b24f 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -55,7 +55,7 @@ /// @return false for an error. bool tabstop_set(char *var, colnr_T **array) { - long valcount = 1; + int valcount = 1; int t; char *cp; @@ -89,7 +89,7 @@ bool tabstop_set(char *var, colnr_T **array) return false; } - *array = (colnr_T *)xmalloc((unsigned)(valcount + 1) * sizeof(long)); + *array = (colnr_T *)xmalloc((unsigned)(valcount + 1) * sizeof(int)); (*array)[0] = (colnr_T)valcount; t = 1; @@ -122,13 +122,13 @@ int tabstop_padding(colnr_T col, OptInt ts_arg, const colnr_T *vts) OptInt ts = ts_arg == 0 ? 8 : ts_arg; colnr_T tabcol = 0; int t; - long padding = 0; + int padding = 0; if (vts == NULL || vts[0] == 0) { return (int)(ts - (col % ts)); } - const long tabcount = vts[0]; + const int tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { tabcol += vts[t]; @@ -141,7 +141,7 @@ int tabstop_padding(colnr_T col, OptInt ts_arg, const colnr_T *vts) padding = vts[tabcount] - ((col - tabcol) % vts[tabcount]); } - return (int)padding; + return padding; } /// Find the size of the tab that covers a particular column. @@ -149,13 +149,13 @@ int tabstop_at(colnr_T col, OptInt ts, const colnr_T *vts) { colnr_T tabcol = 0; int t; - long tab_size = 0; + int tab_size = 0; if (vts == NULL || vts[0] == 0) { return (int)ts; } - const long tabcount = vts[0]; + const int tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { tabcol += vts[t]; if (tabcol > col) { @@ -167,20 +167,20 @@ int tabstop_at(colnr_T col, OptInt ts, const colnr_T *vts) tab_size = vts[tabcount]; } - return (int)tab_size; + return tab_size; } /// Find the column on which a tab starts. -colnr_T tabstop_start(colnr_T col, long ts, colnr_T *vts) +colnr_T tabstop_start(colnr_T col, int ts, colnr_T *vts) { colnr_T tabcol = 0; int t; if (vts == NULL || vts[0] == 0) { - return (int)((col / ts) * ts); + return ((col / ts) * ts); } - const long tabcount = vts[0]; + const int tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { tabcol += vts[t]; if (tabcol > col) { @@ -194,26 +194,26 @@ colnr_T tabstop_start(colnr_T col, long ts, colnr_T *vts) /// Find the number of tabs and spaces necessary to get from one column /// to another. -void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const colnr_T *vts, int *ntabs, +void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts_arg, const colnr_T *vts, int *ntabs, int *nspcs) { int spaces = end_col - start_col; colnr_T tabcol = 0; - long padding = 0; + int padding = 0; int t; - long ts = ts_arg == 0 ? (long)curbuf->b_p_ts : ts_arg; + int ts = ts_arg == 0 ? (int)curbuf->b_p_ts : ts_arg; assert(ts != 0); // suppress clang "Division by zero" if (vts == NULL || vts[0] == 0) { int tabs = 0; - const int initspc = (int)(ts - (start_col % ts)); + const int initspc = (ts - (start_col % ts)); if (spaces >= initspc) { spaces -= initspc; tabs++; } - tabs += (int)(spaces / ts); - spaces -= (int)((spaces / ts) * ts); + tabs += (spaces / ts); + spaces -= ((spaces / ts) * ts); *ntabs = tabs; *nspcs = spaces; @@ -221,7 +221,7 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const colnr } // Find the padding needed to reach the next tabstop. - const long tabcount = vts[0]; + const int tabcount = vts[0]; for (t = 1; t <= tabcount; t++) { tabcol += vts[t]; if (tabcol > start_col) { @@ -241,7 +241,7 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const colnr } *ntabs = 1; - spaces -= (int)padding; + spaces -= padding; // At least one tab has been used. See if any more will fit. while (spaces != 0 && ++t <= tabcount) { @@ -251,7 +251,7 @@ void tabstop_fromto(colnr_T start_col, colnr_T end_col, long ts_arg, const colnr return; } *ntabs += 1; - spaces -= (int)padding; + spaces -= padding; } *ntabs += spaces / (int)vts[tabcount]; @@ -283,21 +283,21 @@ bool tabstop_eq(const colnr_T *ts1, const colnr_T *ts2) } /// Copy a tabstop array, allocating space for the new array. -int *tabstop_copy(const long *oldts) +int *tabstop_copy(const int *oldts) { - long *newts; + int *newts; int t; if (oldts == 0) { return 0; } - newts = xmalloc((unsigned)(oldts[0] + 1) * sizeof(long)); + newts = xmalloc((unsigned)(oldts[0] + 1) * sizeof(int)); for (t = 0; t <= oldts[0]; t++) { newts[t] = oldts[t]; } - return (int *)newts; + return newts; } /// Return a count of the number of tabstops. @@ -316,25 +316,23 @@ int tabstop_first(colnr_T *ts) /// 'tabstop' value when 'shiftwidth' is zero. int get_sw_value(buf_T *buf) { - long result = get_sw_value_col(buf, 0); - assert(result >= 0 && result <= INT_MAX); - return (int)result; + int result = get_sw_value_col(buf, 0); + return result; } /// Idem, using "pos". -long get_sw_value_pos(buf_T *buf, pos_T *pos) +int get_sw_value_pos(buf_T *buf, pos_T *pos) { pos_T save_cursor = curwin->w_cursor; - long sw_value; curwin->w_cursor = *pos; - sw_value = get_sw_value_col(buf, get_nolist_virtcol()); + int sw_value = get_sw_value_col(buf, get_nolist_virtcol()); curwin->w_cursor = save_cursor; return sw_value; } /// Idem, using the first non-black in the current line. -long get_sw_value_indent(buf_T *buf) +int get_sw_value_indent(buf_T *buf) { pos_T pos = curwin->w_cursor; @@ -343,9 +341,9 @@ long get_sw_value_indent(buf_T *buf) } /// Idem, using virtual column "col". -long get_sw_value_col(buf_T *buf, colnr_T col) +int get_sw_value_col(buf_T *buf, colnr_T col) { - return buf->b_p_sw ? (long)buf->b_p_sw + return buf->b_p_sw ? (int)buf->b_p_sw : tabstop_at(col, buf->b_p_ts, buf->b_p_vts_array); } @@ -940,12 +938,12 @@ void ex_retab(exarg_T *eap) { linenr_T lnum; bool got_tab = false; - long num_spaces = 0; - long num_tabs; - long len; - long start_col = 0; // For start of white-space string - long start_vcol = 0; // For start of white-space string - long old_len; + int num_spaces = 0; + int num_tabs; + int len; + int start_col = 0; // For start of white-space string + int64_t start_vcol = 0; // For start of white-space string + int old_len; char *new_line = (char *)1; // init to non-NULL colnr_T *new_vts_array = NULL; char *new_ts_str; // string value of tab argument @@ -976,8 +974,8 @@ void ex_retab(exarg_T *eap) } for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) { char *ptr = ml_get(lnum); - long col = 0; - long vcol = 0; + int col = 0; + int64_t vcol = 0; bool did_undo = false; // called u_save for current line while (true) { if (ascii_iswhite(ptr[col])) { @@ -996,13 +994,13 @@ void ex_retab(exarg_T *eap) // Retabulate this string of white-space // len is virtual length of white string - len = num_spaces = vcol - start_vcol; + len = num_spaces = (int)(vcol - start_vcol); num_tabs = 0; if (!curbuf->b_p_et) { int t, s; tabstop_fromto((colnr_T)start_vcol, (colnr_T)vcol, - (long)curbuf->b_p_ts, new_vts_array, &t, &s); + (int)curbuf->b_p_ts, new_vts_array, &t, &s); num_tabs = t; num_spaces = s; } @@ -1019,7 +1017,7 @@ void ex_retab(exarg_T *eap) // len is actual number of white characters used len = num_spaces + num_tabs; - old_len = (long)strlen(ptr); + old_len = (int)strlen(ptr); const long new_len = old_len - col + start_col + len + 1; if (new_len <= 0 || new_len >= MAXCOL) { emsg_text_too_long(); @@ -1031,7 +1029,7 @@ void ex_retab(exarg_T *eap) memmove(new_line, ptr, (size_t)start_col); } memmove(new_line + start_col + len, - ptr + col, (size_t)(old_len - col + 1)); + ptr + col, (size_t)old_len - (size_t)col + 1); ptr = new_line + start_col; for (col = 0; col < len; col++) { ptr[col] = (col < num_tabs) ? '\t' : ' '; -- cgit From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/indent.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index d19164b24f..65eabd72c3 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -800,7 +800,7 @@ int get_breakindent_win(win_T *wp, char *line) FUNC_ATTR_NONNULL_ALL { static int prev_indent = 0; // cached indent value - static OptInt prev_ts = 0L; // cached tabstop value + static OptInt prev_ts = 0; // cached tabstop value static int prev_fnum = 0; // cached buffer number static char *prev_line = NULL; // cached copy of "line" static varnumber_T prev_tick = 0; // changedtick of cached value @@ -1018,7 +1018,7 @@ void ex_retab(exarg_T *eap) // len is actual number of white characters used len = num_spaces + num_tabs; old_len = (int)strlen(ptr); - const long new_len = old_len - col + start_col + len + 1; + const int new_len = old_len - col + start_col + len + 1; if (new_len <= 0 || new_len >= MAXCOL) { emsg_text_too_long(); break; @@ -1083,7 +1083,7 @@ void ex_retab(exarg_T *eap) redraw_curbuf_later(UPD_NOT_VALID); } if (first_line != 0) { - changed_lines(curbuf, first_line, 0, last_line + 1, 0L, true); + changed_lines(curbuf, first_line, 0, last_line + 1, 0, true); } curwin->w_p_list = save_list; // restore 'list' -- cgit From cd63a9addd6e1114c3524fa041ece560550cfe7b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 10 Nov 2023 08:39:21 +0800 Subject: refactor: change some xstrndup() and xstrnsave() to xmemdupz() (#25959) When the given length is exactly the number of bytes to copy, xmemdupz() makes the intention clearer. --- src/nvim/indent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 65eabd72c3..ff21b11abb 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -960,7 +960,7 @@ void ex_retab(exarg_T *eap) return; } while (ascii_isdigit(*(eap->arg)) || *(eap->arg) == ',') { - (eap->arg)++; + eap->arg++; } // This ensures that either new_vts_array and new_ts_str are freshly @@ -970,7 +970,7 @@ void ex_retab(exarg_T *eap) new_vts_array = curbuf->b_p_vts_array; new_ts_str = NULL; } else { - new_ts_str = xstrnsave(new_ts_str, (size_t)(eap->arg - new_ts_str)); + new_ts_str = xmemdupz(new_ts_str, (size_t)(eap->arg - new_ts_str)); } for (lnum = eap->line1; !got_int && lnum <= eap->line2; lnum++) { char *ptr = ml_get(lnum); -- cgit From 8e58d37f2e15ac8540377148e55ed08a039aadb6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 11 Nov 2023 11:20:08 +0100 Subject: refactor: remove redundant casts --- src/nvim/indent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index ff21b11abb..05a4fd1450 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -731,7 +731,7 @@ int get_number_indent(linenr_T lnum) // vim_regexec() expects a pointer to a line. This lets us // start matching for the flp beyond any comment leader... - if (vim_regexec(®match, ml_get(lnum) + lead_len, (colnr_T)0)) { + if (vim_regexec(®match, ml_get(lnum) + lead_len, 0)) { pos.lnum = lnum; pos.col = (colnr_T)(*regmatch.endp - ml_get(lnum)); pos.coladd = 0; -- cgit From 353a4be7e84fdc101318215bdcc8a7e780d737fe Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 13:13:58 +0100 Subject: build: remove PVS We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable. --- src/nvim/indent.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 05a4fd1450..1bf2379bd9 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include -- cgit From bb4b4576e384c71890b4df4fa4f1ae76fad3a59d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Nov 2023 10:55:54 +0800 Subject: refactor: iwyu (#26062) --- src/nvim/indent.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 1bf2379bd9..89cf374152 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -1,5 +1,4 @@ #include -#include #include #include #include -- cgit From ac1113ded5f8f09dd99a9894d7a7e795626fb728 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 13 Nov 2023 23:40:37 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment --- src/nvim/indent.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 89cf374152..6b08239f85 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -1183,15 +1183,15 @@ int get_expr_indent(void) // I tried to fix the first two issues. int get_lisp_indent(void) { - pos_T *pos, realpos, paren; + pos_T *pos; + pos_T paren; int amount; char *that; - int vi_lisp; // Set vi_lisp to use the vi-compatible method. - vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL); + int vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL); - realpos = curwin->w_cursor; + pos_T realpos = curwin->w_cursor; curwin->w_cursor.col = 0; if ((pos = findmatch(NULL, '(')) == NULL) { -- cgit From a6e3d93421ba13c407a96fac9cc01fa41ec7ad98 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Thu, 16 Nov 2023 10:59:11 +0100 Subject: refactor: enable formatting for ternaries This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators. --- src/nvim/indent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 6b08239f85..0b5606acae 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -888,7 +888,7 @@ int get_breakindent_win(win_T *wp, char *line) // always leave at least bri_min characters on the left, // if text width is sufficient bri = (eff_wwidth - wp->w_briopt_min < 0) - ? 0 : eff_wwidth - wp->w_briopt_min; + ? 0 : eff_wwidth - wp->w_briopt_min; } return bri; -- cgit From 8b428ca8b79ebb7b36c3e403ff3bcb6924a635a6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 16:00:21 +0100 Subject: build(IWYU): fix includes for func_attr.h --- src/nvim/indent.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 0b5606acae..35252cf7e4 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -17,6 +17,7 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/extmark.h" +#include "nvim/func_attr.h" #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/indent.h" -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/indent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 35252cf7e4..3b3f59f995 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -33,7 +33,7 @@ #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/plines.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/regexp.h" #include "nvim/search.h" #include "nvim/strings.h" -- cgit From 6c14ae6bfaf51415b555e9a6b85d1d280976358d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 20:27:32 +0100 Subject: refactor: rename types.h to types_defs.h --- src/nvim/indent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 3b3f59f995..2984a0abef 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -38,7 +38,7 @@ #include "nvim/search.h" #include "nvim/strings.h" #include "nvim/textformat.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #include "nvim/undo.h" #include "nvim/vim.h" -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/indent.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 2984a0abef..e3ba395164 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -4,8 +4,8 @@ #include #include -#include "nvim/ascii.h" -#include "nvim/assert.h" +#include "nvim/ascii_defs.h" +#include "nvim/assert_defs.h" #include "nvim/buffer.h" #include "nvim/change.h" #include "nvim/charset.h" @@ -40,7 +40,7 @@ #include "nvim/textformat.h" #include "nvim/types_defs.h" #include "nvim/undo.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "indent.c.generated.h" -- cgit From a6cba103cebce535279db197f9efeb34e9d1171f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 29 Nov 2023 20:32:40 +0800 Subject: refactor: move some constants out of vim_defs.h (#26298) --- src/nvim/indent.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/indent.c') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index e3ba395164..348f3a6528 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -36,6 +36,7 @@ #include "nvim/pos_defs.h" #include "nvim/regexp.h" #include "nvim/search.h" +#include "nvim/state_defs.h" #include "nvim/strings.h" #include "nvim/textformat.h" #include "nvim/types_defs.h" @@ -1369,11 +1370,11 @@ int get_lisp_indent(void) static int lisp_match(char *p) { - char buf[LSIZE]; + char buf[512]; char *word = *curbuf->b_p_lw != NUL ? curbuf->b_p_lw : p_lispwords; while (*word != NUL) { - (void)copy_option_part(&word, buf, LSIZE, ","); + (void)copy_option_part(&word, buf, sizeof(buf), ","); int len = (int)strlen(buf); if ((strncmp(buf, p, (size_t)len) == 0) && ascii_iswhite_or_nul(p[len])) { -- cgit