aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/help.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-03 20:46:01 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-03 21:21:47 +0800
commitbf4bf7f9e034ca2262e53e347ecb87054aa688d7 (patch)
tree3d3c871422999d8288a531f59d187c1e5411aefc /src/nvim/help.c
parent3838ee63d0af8021b506b8d1c3bb9a4ce961fb8c (diff)
downloadrneovim-bf4bf7f9e034ca2262e53e347ecb87054aa688d7.tar.gz
rneovim-bf4bf7f9e034ca2262e53e347ecb87054aa688d7.tar.bz2
rneovim-bf4bf7f9e034ca2262e53e347ecb87054aa688d7.zip
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 <carlo@cteubner.net>
Diffstat (limited to 'src/nvim/help.c')
-rw-r--r--src/nvim/help.c15
1 files changed, 14 insertions, 1 deletions
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();
}