aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/help.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-03 21:44:13 +0800
committerGitHub <noreply@github.com>2022-12-03 21:44:13 +0800
commite642825e281b7a9f259b8bc0b83b94a78b18a2c4 (patch)
tree846f82101d13a45c8c5faf26971472ea880af4ea /src/nvim/help.c
parentc768b578faba671beab435954dc4e5a321c94728 (diff)
parent0cb90114d4c4801457e286c9b72ad0f394877d05 (diff)
downloadrneovim-e642825e281b7a9f259b8bc0b83b94a78b18a2c4.tar.gz
rneovim-e642825e281b7a9f259b8bc0b83b94a78b18a2c4.tar.bz2
rneovim-e642825e281b7a9f259b8bc0b83b94a78b18a2c4.zip
Merge pull request #21274 from zeertzjq/vim-8.2.3992
vim-patch:8.2.{3992,4261,4262},9.0.{0110,0577}
Diffstat (limited to 'src/nvim/help.c')
-rw-r--r--src/nvim/help.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/nvim/help.c b/src/nvim/help.c
index cdd930203f..2095925db3 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;
@@ -943,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) {
@@ -973,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 '*'.
@@ -992,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);
@@ -1003,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();
}