perl/Module-Pluggable: update to 6.3
[oi-userland.git] / components / editor / vim / patches / help.patch
blob0ce41a0bc0cb48db2f89d766780da7530bc6eed5
1 --- vim-8.2.1897/src/help.c 2020-10-24 17:19:16.000000000 +0000
2 +++ vim-8.2.1897/src/help.c 2020-10-24 18:42:52.206685850 +0000
3 @@ -38,6 +38,8 @@ ex_help(exarg_T *eap)
4 #ifdef FEAT_FOLDING
5 int old_KeyTyped = KeyTyped;
6 #endif
7 + int nohelp = FALSE, nominhelp = FALSE;
8 + char_u *mhf = NULL;
10 if (ERROR_IF_ANY_POPUP_WINDOW)
11 return;
12 @@ -88,6 +90,23 @@ ex_help(exarg_T *eap)
13 n = find_help_tags(arg, &num_matches, &matches,
14 eap != NULL && eap->forceit);
16 + /*
17 + * If we didn't find the help topic, check to see whether 'helpfile'
18 + * (typically $VIMRUNTIME/doc/help.txt) exists. If not, then we'll send the
19 + * user to the minimized help file delivered with the core vim package which
20 + * explains why there's no help and how to get it.
21 + */
22 + if (num_matches == 0 && mch_access((char *)p_hf, F_OK) < 0) {
23 + nohelp = TRUE;
24 + mhf = alloc(MAXPATHL);
25 + STRNCPY(mhf, p_hf, MAXPATHL - 1);
26 + mhf[STRLEN(mhf) - 8] = '\0';
27 + STRNCAT(mhf, "help_minimized.txt", MAXPATHL - STRLEN(mhf) - 1);
29 + if (mch_access((char *)mhf, F_OK) < 0)
30 + nominhelp = TRUE;
31 + }
33 i = 0;
34 #ifdef FEAT_MULTI_LANG
35 if (n != FAIL && lang != NULL)
36 @@ -100,7 +119,7 @@ ex_help(exarg_T *eap)
37 break;
39 #endif
40 - if (i >= num_matches || n == FAIL)
41 + if (!nohelp && i >= num_matches || n == FAIL)
43 #ifdef FEAT_MULTI_LANG
44 if (lang != NULL)
45 @@ -113,9 +132,11 @@ ex_help(exarg_T *eap)
46 return;
49 - // The first match (in the requested language) is the best match.
50 - tag = vim_strsave(matches[i]);
51 - FreeWild(num_matches, matches);
52 + if (!nohelp) {
53 + /* The first match (in the requested language) is the best match. */
54 + tag = vim_strsave(matches[i]);
55 + FreeWild(num_matches, matches);
56 + }
58 #ifdef FEAT_GUI
59 need_mouse_correct = TRUE;
60 @@ -137,12 +158,14 @@ ex_help(exarg_T *eap)
62 // There is no help window yet.
63 // Try to open the file specified by the "helpfile" option.
64 - if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
65 - {
66 - smsg(_("Sorry, help file \"%s\" not found"), p_hf);
67 - goto erret;
68 + if (!nohelp || nominhelp) {
69 + if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
70 + {
71 + smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
72 + goto erret;
73 + }
74 + fclose(helpfd);
76 - fclose(helpfd);
78 // Split off help window; put it at far top if no position
79 // specified, the current window is vertically split and
80 @@ -161,7 +184,7 @@ ex_help(exarg_T *eap)
81 // set b_p_ro flag).
82 // Set the alternate file to the previously edited file.
83 alt_fnum = curbuf->b_fnum;
84 - (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
85 + (void)do_ecmd(0, mhf, NULL, NULL, ECMD_LASTL,
86 ECMD_HIDE + ECMD_SET_HELP,
87 NULL); // buffer is still open, don't store info
88 if (!cmdmod.keepalt)
89 @@ -179,7 +202,7 @@ ex_help(exarg_T *eap)
90 KeyTyped = old_KeyTyped;
91 #endif
93 - if (tag != NULL)
94 + if (!nohelp && tag != NULL)
95 do_tag(tag, DT_HELP, 1, FALSE, TRUE);
97 // Delete the empty buffer if we're not using it. Careful: autocommands
98 @@ -197,7 +220,8 @@ ex_help(exarg_T *eap)
99 curwin->w_alt_fnum = alt_fnum;
101 erret:
102 - vim_free(tag);
103 + if (!nohelp)
104 + vim_free(tag);