7047N/A--- a/src/ex_cmds.c 2016-09-21 15:16:13.032570431 -0700
7047N/A+++ b/src/ex_cmds.c 2016-09-21 15:16:13.055466074 -0700
7047N/A@@ -6276,6 +6276,8 @@
7047N/A #ifdef FEAT_FOLDING
7047N/A int old_KeyTyped = KeyTyped;
379N/A #endif
379N/A+ int nohelp = FALSE, nominhelp = FALSE;
379N/A+ char_u *mhf = NULL;
379N/A
379N/A if (eap != NULL)
379N/A {
7047N/A@@ -6327,6 +6329,23 @@
379N/A n = find_help_tags(arg, &num_matches, &matches,
379N/A eap != NULL && eap->forceit);
379N/A
379N/A+ /*
379N/A+ * If we didn't find the help topic, check to see whether 'helpfile'
379N/A+ * (typically $VIMRUNTIME/doc/help.txt) exists. If not, then we'll send the
379N/A+ * user to the minimized help file delivered with the core vim package which
379N/A+ * explains why there's no help and how to get it.
379N/A+ */
379N/A+ if (num_matches == 0 && mch_access((char *)p_hf, F_OK) < 0) {
379N/A+ nohelp = TRUE;
379N/A+ mhf = alloc(MAXPATHL);
379N/A+ STRNCPY(mhf, p_hf, MAXPATHL - 1);
379N/A+ mhf[STRLEN(mhf) - 8] = '\0';
379N/A+ STRNCAT(mhf, "help_minimized.txt", MAXPATHL - STRLEN(mhf) - 1);
379N/A+
379N/A+ if (mch_access((char *)mhf, F_OK) < 0)
379N/A+ nominhelp = TRUE;
379N/A+ }
379N/A+
379N/A i = 0;
379N/A #ifdef FEAT_MULTI_LANG
379N/A if (n != FAIL && lang != NULL)
7047N/A@@ -6339,7 +6358,7 @@
379N/A break;
379N/A }
379N/A #endif
379N/A- if (i >= num_matches || n == FAIL)
379N/A+ if (!nohelp && i >= num_matches || n == FAIL)
379N/A {
379N/A #ifdef FEAT_MULTI_LANG
379N/A if (lang != NULL)
7047N/A@@ -6352,9 +6371,11 @@
379N/A return;
379N/A }
379N/A
379N/A- /* The first match (in the requested language) is the best match. */
379N/A- tag = vim_strsave(matches[i]);
379N/A- FreeWild(num_matches, matches);
379N/A+ if (!nohelp) {
379N/A+ /* The first match (in the requested language) is the best match. */
379N/A+ tag = vim_strsave(matches[i]);
379N/A+ FreeWild(num_matches, matches);
379N/A+ }
379N/A
379N/A #ifdef FEAT_GUI
379N/A need_mouse_correct = TRUE;
7047N/A@@ -6386,12 +6407,14 @@
379N/A * There is no help window yet.
379N/A * Try to open the file specified by the "helpfile" option.
379N/A */
379N/A- if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
379N/A- {
379N/A- smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
379N/A- goto erret;
379N/A+ if (!nohelp || nominhelp) {
379N/A+ if ((helpfd = mch_fopen((char *)p_hf, READBIN)) == NULL)
379N/A+ {
379N/A+ smsg((char_u *)_("Sorry, help file \"%s\" not found"), p_hf);
379N/A+ goto erret;
379N/A+ }
379N/A+ fclose(helpfd);
379N/A }
379N/A- fclose(helpfd);
379N/A
379N/A #ifdef FEAT_WINDOWS
379N/A /* Split off help window; put it at far top if no position
7047N/A@@ -6420,7 +6443,7 @@
379N/A * Set the alternate file to the previously edited file.
379N/A */
379N/A alt_fnum = curbuf->b_fnum;
379N/A- (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
379N/A+ (void)do_ecmd(0, mhf, NULL, NULL, ECMD_LASTL,
379N/A ECMD_HIDE + ECMD_SET_HELP,
379N/A #ifdef FEAT_WINDOWS
379N/A NULL /* buffer is still open, don't store info */
7047N/A@@ -6443,7 +6466,7 @@
7047N/A KeyTyped = old_KeyTyped;
7047N/A #endif
379N/A
379N/A- if (tag != NULL)
379N/A+ if (!nohelp && tag != NULL)
379N/A do_tag(tag, DT_HELP, 1, FALSE, TRUE);
379N/A
379N/A /* Delete the empty buffer if we're not using it. Careful: autocommands
7047N/A@@ -6461,7 +6484,8 @@
379N/A curwin->w_alt_fnum = alt_fnum;
379N/A
379N/A erret:
379N/A- vim_free(tag);
379N/A+ if (!nohelp)
379N/A+ vim_free(tag);
379N/A }
379N/A
7047N/A /*