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)
5 int old_KeyTyped = KeyTyped;
7 + int nohelp = FALSE, nominhelp = FALSE;
10 if (ERROR_IF_ANY_POPUP_WINDOW)
12 @@ -88,6 +90,23 @@ ex_help(exarg_T *eap)
13 n = find_help_tags(arg, &num_matches, &matches,
14 eap != NULL && eap->forceit);
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.
22 + if (num_matches == 0 && mch_access((char *)p_hf, F_OK) < 0) {
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)
34 #ifdef FEAT_MULTI_LANG
35 if (n != FAIL && lang != NULL)
36 @@ -100,7 +119,7 @@ ex_help(exarg_T *eap)
40 - if (i >= num_matches || n == FAIL)
41 + if (!nohelp && i >= num_matches || n == FAIL)
43 #ifdef FEAT_MULTI_LANG
45 @@ -113,9 +132,11 @@ ex_help(exarg_T *eap)
49 - // The first match (in the requested language) is the best match.
50 - tag = vim_strsave(matches[i]);
51 - FreeWild(num_matches, matches);
53 + /* The first match (in the requested language) is the best match. */
54 + tag = vim_strsave(matches[i]);
55 + FreeWild(num_matches, matches);
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)
66 - smsg(_("Sorry, help file \"%s\" not found"), p_hf);
68 + if (!nohelp || nominhelp) {
69 + if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
71 + smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
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)
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
89 @@ -179,7 +202,7 @@ ex_help(exarg_T *eap)
90 KeyTyped = old_KeyTyped;
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;