From b69c5817619c8922039e75e9aaaed06ae35ee002 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 3 Dec 2022 19:09:19 +0800 Subject: vim-patch:8.2.3992: wrong local-additions in the help with language mix Problem: Wrong local-additions in the help with language mix. Solution: Adjust how the local additions list is generated. (Hirohito Higashi, closes vim/vim#9464) https://github.com/vim/vim/commit/0e2508d9e63e63414de2c06b3c8a446fdfe4470b Co-authored-by: h-east --- src/nvim/help.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index cdd930203f..37d240e5c6 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -743,28 +743,26 @@ void fix_help_buffer(void) // If foo.abx is found use it instead of foo.txt in // the same directory. for (int i1 = 0; i1 < fcount; i1++) { - for (int i2 = 0; i2 < fcount; i2++) { - if (i1 == i2) { - continue; - } - if (fnames[i1] == NULL || fnames[i2] == NULL) { + const char *const f1 = fnames[i1]; + const char *const t1 = path_tail(f1); + const char *const e1 = strrchr(t1, '.'); + if (path_fnamecmp(e1, ".txt") != 0 + && path_fnamecmp(e1, fname + 4) != 0) { + // Not .txt and not .abx, remove it. + XFREE_CLEAR(fnames[i1]); + continue; + } + + for (int i2 = i1 + 1; i2 < fcount; i2++) { + const char *const f2 = fnames[i2]; + if (f2 == NULL) { continue; } - const char *const f1 = fnames[i1]; - const char *const f2 = fnames[i2]; - const char *const t1 = path_tail(f1); const char *const t2 = path_tail(f2); - const char *const e1 = strrchr(t1, '.'); const char *const e2 = strrchr(t2, '.'); if (e1 == NULL || e2 == NULL) { continue; } - if (path_fnamecmp(e1, ".txt") != 0 - && path_fnamecmp(e1, fname + 4) != 0) { - // Not .txt and not .abx, remove it. - XFREE_CLEAR(fnames[i1]); - continue; - } if (e1 - f1 != e2 - f2 || path_fnamencmp(f1, f2, (size_t)(e1 - f1)) != 0) { continue; -- cgit From bf4bf7f9e034ca2262e53e347ecb87054aa688d7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 3 Dec 2022 20:46:01 +0800 Subject: vim-patch:9.0.0110: help tag generation picks up words in code examples Problem: Help tag generation picks up words in code examples. Solution: Skip over examples. (Carlo Teubner, closes vim/vim#10813) https://github.com/vim/vim/commit/ddab3ce3457aadffb16ce0127f67a99966a065a8 Also fix mistakes in help files. Co-authored-by: Carlo Teubner --- src/nvim/help.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/nvim/help.c') diff --git a/src/nvim/help.c b/src/nvim/help.c index 37d240e5c6..2095925db3 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -941,6 +941,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } const char *const fname = files[fi] + dirlen + 1; + bool in_example = false; bool firstline = true; while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) { if (firstline) { @@ -971,6 +972,13 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } firstline = false; } + if (in_example) { + // skip over example; a non-white in the first column ends it + if (vim_strchr(" \t\n\r", IObuff[0])) { + continue; + } + in_example = false; + } p1 = vim_strchr((char *)IObuff, '*'); // find first '*' while (p1 != NULL) { p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'. @@ -990,7 +998,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool || s[1] == '\0')) { *p2 = '\0'; p1++; - size_t s_len= (size_t)(p2 - p1) + strlen(fname) + 2; + size_t s_len = (size_t)(p2 - p1) + strlen(fname) + 2; s = xmalloc(s_len); GA_APPEND(char *, &ga, s); snprintf(s, s_len, "%s\t%s", p1, fname); @@ -1001,6 +1009,11 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool } p1 = p2; } + size_t len = strlen(IObuff); + if ((len == 2 && strcmp(&IObuff[len - 2], ">\n") == 0) + || (len >= 3 && strcmp(&IObuff[len - 3], " >\n") == 0)) { + in_example = true; + } line_breakcheck(); } -- cgit