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/help.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index bbc552fa4c..ab9d68fd89 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -660,7 +660,6 @@ void fix_help_buffer(void) { linenr_T lnum; char *line; - bool in_example = false; // Set filetype to "help". if (strcmp(curbuf->b_p_ft, "help") != 0) { @@ -670,6 +669,7 @@ void fix_help_buffer(void) } if (!syntax_present(curwin)) { + bool in_example = false; for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { line = ml_get_buf(curbuf, lnum, false); const size_t len = strlen(line); @@ -722,9 +722,7 @@ void fix_help_buffer(void) && path_full_compare(rt, NameBuff, false, true) != kEqualFiles) { int fcount; char **fnames; - char *s; vimconv_T vc; - char *cp; // Find all "doc/ *.txt" files in this directory. if (!add_pathsep(NameBuff) @@ -740,6 +738,8 @@ void fix_help_buffer(void) if (gen_expand_wildcards(1, buff_list, &fcount, &fnames, EW_FILE|EW_SILENT) == OK && fcount > 0) { + char *s; + char *cp; // If foo.abx is found use it instead of foo.txt in // the same directory. for (int i1 = 0; i1 < fcount; i1++) { @@ -1080,7 +1080,6 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr) FUNC_ATTR_NONNULL_ALL { - int len; garray_T ga; char lang[2]; char ext[5]; @@ -1111,7 +1110,7 @@ static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr) int j; ga_init(&ga, 1, 10); for (int i = 0; i < filecount; i++) { - len = (int)strlen(files[i]); + int len = (int)strlen(files[i]); if (len <= 4) { continue; } @@ -1177,7 +1176,6 @@ static void helptags_cb(char *fname, void *cookie) void ex_helptags(exarg_T *eap) { expand_T xpc; - char *dirname; bool add_help_tags = false; // Check for ":helptags ++t {dir}". @@ -1191,7 +1189,8 @@ void ex_helptags(exarg_T *eap) } else { ExpandInit(&xpc); xpc.xp_context = EXPAND_DIRECTORIES; - dirname = ExpandOne(&xpc, eap->arg, NULL, WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); + char *dirname = + ExpandOne(&xpc, eap->arg, NULL, WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); if (dirname == NULL || !os_isdir(dirname)) { semsg(_("E150: Not a directory: %s"), eap->arg); } else { -- cgit From 4be6c6cf0ddf5e31d4103cb5df06651ba6f4897b Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:05:57 +0100 Subject: refactor: replace char_u with char (#21901) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index ab9d68fd89..ab4ce4e9ba 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -1089,7 +1089,7 @@ static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr) // Get a list of all files in the help directory and in subdirectories. xstrlcpy(NameBuff, dirname, sizeof(NameBuff)); - if (!add_pathsep((char *)NameBuff) + if (!add_pathsep(NameBuff) || xstrlcat(NameBuff, "**", sizeof(NameBuff)) >= MAXPATHL) { emsg(_(e_fnametoolong)); return; -- cgit From 5f72ab77bff1f1224be5cbbf9423bdddbc25635c Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:48:49 +0100 Subject: refactor: reduce scope of locals as per the style guide 3 (#22221) refactor: reduce scope of locals as per the style guide --- src/nvim/help.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index ab4ce4e9ba..5fa48e0cee 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -47,19 +47,14 @@ void ex_help(exarg_T *eap) { char *arg; - char *tag; FILE *helpfd; // file descriptor of help file - int n; - int i; win_T *wp; int num_matches; char **matches; - char *p; int empty_fnum = 0; int alt_fnum = 0; buf_T *buf; int len; - char *lang; const bool old_KeyTyped = KeyTyped; if (eap != NULL) { @@ -88,13 +83,13 @@ void ex_help(exarg_T *eap) } // remove trailing blanks - p = arg + strlen(arg) - 1; + char *p = arg + strlen(arg) - 1; while (p > arg && ascii_iswhite(*p) && p[-1] != '\\') { *p-- = NUL; } // Check for a specified language - lang = check_help_lang(arg); + char *lang = check_help_lang(arg); // When no argument given go to the index. if (*arg == NUL) { @@ -102,9 +97,9 @@ void ex_help(exarg_T *eap) } // Check if there is a match for the argument. - n = find_help_tags(arg, &num_matches, &matches, eap != NULL && eap->forceit); + int n = find_help_tags(arg, &num_matches, &matches, eap != NULL && eap->forceit); - i = 0; + int i = 0; if (n != FAIL && lang != NULL) { // Find first item with the requested language. for (i = 0; i < num_matches; i++) { @@ -128,7 +123,7 @@ void ex_help(exarg_T *eap) } // The first match (in the requested language) is the best match. - tag = xstrdup(matches[i]); + char *tag = xstrdup(matches[i]); FreeWild(num_matches, matches); // Re-use an existing help window or open a new one. @@ -259,11 +254,8 @@ char *check_help_lang(char *arg) int help_heuristic(char *matched_string, int offset, int wrong_case) FUNC_ATTR_PURE { - int num_letters; - char *p; - - num_letters = 0; - for (p = matched_string; *p; p++) { + int num_letters = 0; + for (char *p = matched_string; *p; p++) { if (ASCII_ISALNUM(*p)) { num_letters++; } @@ -298,11 +290,8 @@ int help_heuristic(char *matched_string, int offset, int wrong_case) /// that has been put after the tagname by find_tags(). static int help_compare(const void *s1, const void *s2) { - char *p1; - char *p2; - - p1 = *(char **)s1 + strlen(*(char **)s1) + 1; - p2 = *(char **)s2 + strlen(*(char **)s2) + 1; + char *p1 = *(char **)s1 + strlen(*(char **)s1) + 1; + char *p2 = *(char **)s2 + strlen(*(char **)s2) + 1; // Compare by help heuristic number first. int cmp = strcmp(p1, p2); @@ -320,8 +309,6 @@ static int help_compare(const void *s1, const void *s2) /// When "keep_lang" is true try keeping the language of the current buffer. int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep_lang) { - int i; - // Specific tags that either have a specific replacement or won't go // through the generic rules. static char *(except_tbl[][2]) = { @@ -379,7 +366,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep // When the string starting with "expr-" and containing '?' and matches // the table, it is taken literally (but ~ is escaped). Otherwise '?' // is recognized as a wildcard. - for (i = (int)ARRAY_SIZE(expr_table); --i >= 0;) { + for (int i = (int)ARRAY_SIZE(expr_table); --i >= 0;) { if (strcmp(arg + 5, expr_table[i]) == 0) { for (int si = 0, di = 0;; si++) { if (arg[si] == '~') { @@ -396,7 +383,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep } else { // Recognize a few exceptions to the rule. Some strings that contain // '*'are changed to "star", otherwise '*' is recognized as a wildcard. - for (i = 0; except_tbl[i][0] != NULL; i++) { + for (int i = 0; except_tbl[i][0] != NULL; i++) { if (strcmp(arg, except_tbl[i][0]) == 0) { STRCPY(d, except_tbl[i][1]); break; -- cgit From 6cab36e5b7b0d741abe6c5a7c0e20bad30361034 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 4 Mar 2023 13:10:00 +0100 Subject: refactor: replace char_u with char or uint8_t (#22400) Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 5fa48e0cee..968f0bc2f4 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -1022,7 +1022,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool *p2 = NUL; vim_snprintf(NameBuff, MAXPATHL, _("E154: Duplicate tag \"%s\" in file %s/%s"), - ((char_u **)ga.ga_data)[i], dir, p2 + 1); + ((char **)ga.ga_data)[i], dir, p2 + 1); emsg(NameBuff); *p2 = '\t'; break; -- cgit From 95ab5a0da3a465351a781031698d6cc8a727584a Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 13 Mar 2023 19:50:09 +0100 Subject: fix(help): force tree reparse after local addition insertion Problem: *local-additions* in `help.txt` are inserted via `ml_append`, which messes up treesitter highlighting of this file as the buffer becomes desynced from the tree. Solution: Add hack on top of hack by explicitly calling `mark_adjust` and `changed_lines_buf` after each insertion. --- src/nvim/help.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 968f0bc2f4..728c890da4 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -10,6 +10,7 @@ #include "nvim/ascii.h" #include "nvim/buffer.h" +#include "nvim/change.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/ex_cmds.h" @@ -699,6 +700,8 @@ void fix_help_buffer(void) continue; } + int lnum_start = lnum; + // Go through all directories in 'runtimepath', skipping // $VIMRUNTIME. char *p = p_rtp; @@ -829,6 +832,11 @@ void fix_help_buffer(void) } xfree(rt); } + linenr_T appended = lnum - lnum_start; + if (appended) { + mark_adjust(lnum_start + 1, (linenr_T)MAXLNUM, appended, 0L, kExtmarkUndo); + changed_lines_buf(curbuf, lnum_start + 1, lnum_start + 1, appended); + } break; } } -- cgit From 9408f2dcf7cade2631688300e9b58eed6bc5219a Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:40:57 +0200 Subject: refactor: remove redundant const char * casts --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 728c890da4..10e9ecf281 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -976,7 +976,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } p1 = vim_strchr(IObuff, '*'); // find first '*' while (p1 != NULL) { - p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'. + p2 = strchr(p1 + 1, '*'); // Find second '*'. if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**". for (s = p1 + 1; s < p2; s++) { if (*s == ' ' || *s == '\t' || *s == '|') { -- cgit From 2d78e656b715119ca11d131a1a932f22f1b4ad36 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Fri, 7 Apr 2023 21:43:00 +0200 Subject: refactor: remove redundant casts --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 10e9ecf281..633e9df244 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -1154,7 +1154,7 @@ static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr) ext[1] = fname[5]; ext[2] = fname[6]; } - helptags_one(dirname, (char *)ext, (char *)fname, add_help_tags, ignore_writeerr); + helptags_one(dirname, ext, fname, add_help_tags, ignore_writeerr); } ga_clear(&ga); -- cgit From 6a273af10517d1f7e4ea85635f1d25a9158adeb5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 13 May 2023 10:40:53 +0800 Subject: refactor: remove typval.h from most header files (#23601) Because typval_defs.h is enough for most of them. --- src/nvim/help.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 633e9df244..d412f3a098 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -22,6 +22,7 @@ #include "nvim/globals.h" #include "nvim/help.h" #include "nvim/macros.h" +#include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" -- cgit From b3d5138fd0066fda26ef7724a542ae45eb42fc84 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Wed, 7 Jun 2023 06:05:16 +0600 Subject: refactor(options): remove `getoption_T` and introduce `OptVal` (#23850) Removes the `getoption_T` struct and also introduces the `OptVal` struct to unify the methods of getting/setting different option value types. This is the first of many PRs to reduce code duplication in the Vim option code as well as to make options easier to maintain. It also increases the flexibility and extensibility of options. Which opens the door for things like Array and Dictionary options. --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index d412f3a098..46310cb681 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -653,7 +653,7 @@ void fix_help_buffer(void) // Set filetype to "help". if (strcmp(curbuf->b_p_ft, "help") != 0) { curbuf->b_ro_locked++; - set_option_value_give_err("ft", 0L, "help", OPT_LOCAL); + set_option_value_give_err("ft", STATIC_CSTR_AS_OPTVAL("help"), OPT_LOCAL); curbuf->b_ro_locked--; } -- cgit From 4229bbe514b7a1bc5b9f888a294cc8a323a7d869 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Jun 2023 12:23:11 +0800 Subject: fix(helptags): make multibyte help tags work properly (#23975) --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 46310cb681..8c7c19e7c3 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -458,7 +458,7 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep // Replace "^x" by "CTRL-X". Don't do this for "^_" to make // ":help i_^_CTRL-D" work. // Insert '-' before and after "CTRL-X" when applicable. - if (*s < ' ' + if ((uint8_t)(*s) < ' ' || (*s == '^' && s[1] && (ASCII_ISALPHA(s[1]) || vim_strchr("?@[\\]^", (uint8_t)s[1]) != NULL))) { if (d > IObuff && d[-1] != '_' && d[-1] != '\\') { -- cgit From 516b173780e39de3ce1e4525f0a8f0ff250c992b Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 13 Jul 2023 10:17:19 +0100 Subject: perf(rtp): reduce rtp scans (#24191) * perf(rtp): reduce rtp scans Problem: Scanning the filesystem is expensive and particularly affects startuptime. Solution: Reduce the amount of redundant directory scans by relying less on glob patterns and handle vim and lua sourcing lower down. --- src/nvim/help.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 8c7c19e7c3..4602ddd40e 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -1162,10 +1162,17 @@ static void do_helptags(char *dirname, bool add_help_tags, bool ignore_writeerr) FreeWild(filecount, files); } -static void helptags_cb(char *fname, void *cookie) +static bool helptags_cb(int num_fnames, char **fnames, bool all, void *cookie) FUNC_ATTR_NONNULL_ALL { - do_helptags(fname, *(bool *)cookie, true); + for (int i = 0; i < num_fnames; i++) { + do_helptags(fnames[i], *(bool *)cookie, true); + if (!all) { + return true; + } + } + + return num_fnames > 0; } /// ":helptags" -- cgit From 46163ddf5d718c4e749df78ef8e54d0715de6cb9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Aug 2023 08:24:49 +0800 Subject: vim-patch:9.0.1730: passing multiple patterns to runtime not working (#24771) Problem: passing multiple patterns to runtime not working Solution: prepend prefix to each argument separately closes: vim/vim#12617 https://github.com/vim/vim/commit/008c91537b55835aa91cd8fbe1a139256581da31 --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 4602ddd40e..dc384e3d14 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -1188,7 +1188,7 @@ void ex_helptags(exarg_T *eap) } if (strcmp(eap->arg, "ALL") == 0) { - do_in_path(p_rtp, "doc", DIP_ALL + DIP_DIR, helptags_cb, &add_help_tags); + do_in_path(p_rtp, "", "doc", DIP_ALL + DIP_DIR, helptags_cb, &add_help_tags); } else { ExpandInit(&xpc); xpc.xp_context = EXPAND_DIRECTORIES; -- 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/help.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index dc384e3d14..1e21dbba4d 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -660,13 +660,13 @@ void fix_help_buffer(void) if (!syntax_present(curwin)) { bool in_example = false; for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { - line = ml_get_buf(curbuf, lnum, false); + line = ml_get_buf(curbuf, lnum); const size_t len = strlen(line); if (in_example && len > 0 && !ascii_iswhite(line[0])) { // End of example: non-white or '<' in first column. if (line[0] == '<') { // blank-out a '<' in the first column - line = ml_get_buf(curbuf, lnum, true); + line = ml_get_buf_mut(curbuf, lnum); line[0] = ' '; } in_example = false; @@ -674,12 +674,12 @@ void fix_help_buffer(void) if (!in_example && len > 0) { if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) { // blank-out a '>' in the last column (start of example) - line = ml_get_buf(curbuf, lnum, true); + line = ml_get_buf_mut(curbuf, lnum); line[len - 1] = ' '; in_example = true; } else if (line[len - 1] == '~') { // blank-out a '~' at the end of line (header marker) - line = ml_get_buf(curbuf, lnum, true); + line = ml_get_buf_mut(curbuf, lnum); line[len - 1] = ' '; } } @@ -696,7 +696,7 @@ void fix_help_buffer(void) && TOLOWER_ASC(fname[7]) == 'x' && fname[8] == NUL)) { for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) { - line = ml_get_buf(curbuf, lnum, false); + line = ml_get_buf(curbuf, lnum); if (strstr(line, "*local-additions*") == NULL) { continue; } -- 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/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 1e21dbba4d..698eda8468 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -836,7 +836,7 @@ void fix_help_buffer(void) linenr_T appended = lnum - lnum_start; if (appended) { mark_adjust(lnum_start + 1, (linenr_T)MAXLNUM, appended, 0L, kExtmarkUndo); - changed_lines_buf(curbuf, lnum_start + 1, lnum_start + 1, appended); + buf_redraw_changed_lines_later(curbuf, lnum_start + 1, lnum_start + 1, appended); } break; } -- cgit From bc13bc154aa574e0bb58a50f2e0ca4570efa57c3 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 29 Sep 2023 16:10:54 +0200 Subject: refactor(message): smsg_attr -> smsg --- src/nvim/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 698eda8468..a32a03de52 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -148,7 +148,7 @@ void ex_help(exarg_T *eap) // There is no help window yet. // Try to open the file specified by the "helpfile" option. if ((helpfd = os_fopen(p_hf, READBIN)) == NULL) { - smsg(_("Sorry, help file \"%s\" not found"), p_hf); + smsg(0, _("Sorry, help file \"%s\" not found"), p_hf); goto erret; } fclose(helpfd); -- 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/help.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index a32a03de52..752f942ec7 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -4,6 +4,7 @@ // help.c: functions for Vim help #include +#include #include #include #include @@ -16,6 +17,7 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" +#include "nvim/extmark_defs.h" #include "nvim/fileio.h" #include "nvim/garray.h" #include "nvim/gettext.h" -- 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/help.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 752f942ec7..d8b6afec27 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -30,6 +30,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option.h" +#include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os.h" -- 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/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index d8b6afec27..3b4889fb0e 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -838,7 +838,7 @@ void fix_help_buffer(void) } linenr_T appended = lnum - lnum_start; if (appended) { - mark_adjust(lnum_start + 1, (linenr_T)MAXLNUM, appended, 0L, kExtmarkUndo); + mark_adjust(lnum_start + 1, (linenr_T)MAXLNUM, appended, 0, kExtmarkUndo); buf_redraw_changed_lines_later(curbuf, lnum_start + 1, lnum_start + 1, appended); } break; -- 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/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 3b4889fb0e..4040c93347 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -823,7 +823,7 @@ void fix_help_buffer(void) } convert_setup(&vc, NULL, NULL); - ml_append(lnum, cp, (colnr_T)0, false); + ml_append(lnum, cp, 0, false); if (cp != IObuff) { xfree(cp); } -- 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/help.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 4040c93347..3e7577505d 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.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 - // help.c: functions for Vim help #include -- cgit From 28f4f3c48498086307ed825d1761edb5789ca0e8 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 12 Nov 2023 15:54:54 +0100 Subject: refactor: follow style guide - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values --- src/nvim/help.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 3e7577505d..14dc7b6623 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -55,8 +55,6 @@ void ex_help(exarg_T *eap) char **matches; int empty_fnum = 0; int alt_fnum = 0; - buf_T *buf; - int len; const bool old_KeyTyped = KeyTyped; if (eap != NULL) { @@ -105,7 +103,7 @@ void ex_help(exarg_T *eap) if (n != FAIL && lang != NULL) { // Find first item with the requested language. for (i = 0; i < num_matches; i++) { - len = (int)strlen(matches[i]); + int len = (int)strlen(matches[i]); if (len > 3 && matches[i][len - 3] == '@' && STRICMP(matches[i] + len - 2, lang) == 0) { break; @@ -196,7 +194,7 @@ void ex_help(exarg_T *eap) // may have jumped to another window, check that the buffer is not in a // window. if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum) { - buf = buflist_findnr(empty_fnum); + buf_T *buf = buflist_findnr(empty_fnum); if (buf != NULL && buf->b_nwindows == 0) { wipe_buffer(buf, true); } @@ -647,9 +645,6 @@ void prepare_help_buffer(void) /// highlighting is not used. void fix_help_buffer(void) { - linenr_T lnum; - char *line; - // Set filetype to "help". if (strcmp(curbuf->b_p_ft, "help") != 0) { curbuf->b_ro_locked++; @@ -659,8 +654,8 @@ void fix_help_buffer(void) if (!syntax_present(curwin)) { bool in_example = false; - for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { - line = ml_get_buf(curbuf, lnum); + for (linenr_T lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { + char *line = ml_get_buf(curbuf, lnum); const size_t len = strlen(line); if (in_example && len > 0 && !ascii_iswhite(line[0])) { // End of example: non-white or '<' in first column. @@ -695,8 +690,8 @@ void fix_help_buffer(void) && ASCII_ISALPHA(fname[6]) && TOLOWER_ASC(fname[7]) == 'x' && fname[8] == NUL)) { - for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) { - line = ml_get_buf(curbuf, lnum); + for (linenr_T lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) { + char *line = ml_get_buf(curbuf, lnum); if (strstr(line, "*local-additions*") == NULL) { continue; } -- 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/help.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 14dc7b6623..337c34f1de 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -865,7 +865,6 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool garray_T ga; int filecount; char **files; - char *p1, *p2; char *s; TriState utf8 = kNone; bool mix = false; // detected mixed encodings @@ -970,9 +969,9 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } in_example = false; } - p1 = vim_strchr(IObuff, '*'); // find first '*' + char *p1 = vim_strchr(IObuff, '*'); // find first '*' while (p1 != NULL) { - p2 = strchr(p1 + 1, '*'); // Find second '*'. + char *p2 = strchr(p1 + 1, '*'); // Find second '*'. if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**". for (s = p1 + 1; s < p2; s++) { if (*s == ' ' || *s == '\t' || *s == '|') { @@ -1019,8 +1018,8 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool // Check for duplicates. for (int i = 1; i < ga.ga_len; i++) { - p1 = ((char **)ga.ga_data)[i - 1]; - p2 = ((char **)ga.ga_data)[i]; + char *p1 = ((char **)ga.ga_data)[i - 1]; + char *p2 = ((char **)ga.ga_data)[i]; while (*p1 == *p2) { if (*p2 == '\t') { *p2 = NUL; @@ -1048,7 +1047,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool fputs(s, fd_tags); } else { fprintf(fd_tags, "%s\t/" "*", s); - for (p1 = s; *p1 != '\t'; p1++) { + for (char *p1 = s; *p1 != '\t'; p1++) { // insert backslash before '\\' and '/' if (*p1 == '\\' || *p1 == '/') { putc('\\', fd_tags); -- cgit From 38a20dd89f91c45ec8589bf1c50d50732882d38a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 20:58:37 +0800 Subject: build(IWYU): replace most private mappings with pragmas (#26247) --- src/nvim/help.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 337c34f1de..b1b2feb587 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -29,6 +29,7 @@ #include "nvim/option.h" #include "nvim/option_vars.h" #include "nvim/optionstr.h" +#include "nvim/os/fs.h" #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/path.h" -- 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/help.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index b1b2feb587..bf8adff2a9 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -16,6 +16,7 @@ #include "nvim/ex_docmd.h" #include "nvim/extmark_defs.h" #include "nvim/fileio.h" +#include "nvim/func_attr.h" #include "nvim/garray.h" #include "nvim/gettext.h" #include "nvim/globals.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/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index bf8adff2a9..5123edc2db 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -34,7 +34,7 @@ #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/path.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" #include "nvim/runtime.h" #include "nvim/strings.h" #include "nvim/syntax.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/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 5123edc2db..0e388d923c 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -39,7 +39,7 @@ #include "nvim/strings.h" #include "nvim/syntax.h" #include "nvim/tag.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" #include "nvim/vim.h" #include "nvim/window.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/help.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 0e388d923c..c23dc7fd9d 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -6,7 +6,7 @@ #include #include -#include "nvim/ascii.h" +#include "nvim/ascii_defs.h" #include "nvim/buffer.h" #include "nvim/change.h" #include "nvim/charset.h" @@ -21,7 +21,7 @@ #include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/help.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" @@ -40,7 +40,7 @@ #include "nvim/syntax.h" #include "nvim/tag.h" #include "nvim/types_defs.h" -#include "nvim/vim.h" +#include "nvim/vim_defs.h" #include "nvim/window.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit