diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-09-30 22:58:42 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-10-01 22:27:45 -0400 |
commit | ada2ec441617077110e503c550dd3227eb9da072 (patch) | |
tree | 5c65085758e309dc8af351fba0beafbd52b605d8 | |
parent | efef797126506e84fadfc7214ffc55aa7c084e80 (diff) | |
download | rneovim-ada2ec441617077110e503c550dd3227eb9da072.tar.gz rneovim-ada2ec441617077110e503c550dd3227eb9da072.tar.bz2 rneovim-ada2ec441617077110e503c550dd3227eb9da072.zip |
vim-patch:8.1.0315: helpgrep with language doesn't work properly
Problem: Helpgrep with language doesn't work properly. (Takuya Fujiwara)
Solution: Check for the language earlier. (Hirohito Higashi)
https://github.com/vim/vim/commit/c631f2df624954184509df49479d52ad7fe5233b
-rw-r--r-- | src/nvim/quickfix.c | 29 | ||||
-rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 14 |
2 files changed, 30 insertions, 13 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 0897367b2d..511fb037fb 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4468,7 +4468,7 @@ void ex_vimgrep(exarg_T *eap) goto theend; } - /* Jump to first match. */ + // Jump to first match. if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { if ((flags & VGR_NOJUMP) == 0) { vgr_jump_to_match(qi, eap->forceit, &redraw_for_dummy, first_match_buf, @@ -5767,14 +5767,14 @@ static void hgr_search_files_in_dir( } } -// Search for a pattern in all the help files in the 'runtimepath'. +// Search for a pattern in all the help files in the 'runtimepath' +// and add the matches to a quickfix list. +// 'lang' is the language specifier. If supplied, then only matches in the +// specified language are found. static void hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, - char_u *arg) - FUNC_ATTR_NONNULL_ALL + const char_u *lang) + FUNC_ATTR_NONNULL_ARG(1, 2) { - // Check for a specified language - char_u *const lang = check_help_lang(arg); - // Go through all directories in 'runtimepath' char_u *p = p_rtp; while (*p != NUL && !got_int) { @@ -5811,6 +5811,8 @@ void ex_helpgrep(exarg_T *eap) qi = hgr_get_ll(&new_qi); } + // Check for a specified language + char_u *const lang = check_help_lang(eap->arg); regmatch_T regmatch = { .regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING), .rm_ic = false, @@ -5819,7 +5821,7 @@ void ex_helpgrep(exarg_T *eap) // Create a new quickfix list. qf_new_list(qi, qf_cmdtitle(*eap->cmdlinep)); - hgr_search_in_rtp(qi, ®match, eap->arg); + hgr_search_in_rtp(qi, ®match, lang); vim_regfree(regmatch.regprog); @@ -5829,11 +5831,12 @@ void ex_helpgrep(exarg_T *eap) qi->qf_lists[qi->qf_curlist].qf_index = 1; } - if (p_cpo == empty_option) + if (p_cpo == empty_option) { p_cpo = save_cpo; - else - /* Darn, some plugin changed the value. */ + } else { + // Darn, some plugin changed the value. free_string_option(save_cpo); + } qf_list_changed(qi, qi->qf_curlist); qf_update_buffer(qi, NULL); @@ -5854,8 +5857,8 @@ void ex_helpgrep(exarg_T *eap) EMSG2(_(e_nomatch2), eap->arg); if (eap->cmdidx == CMD_lhelpgrep) { - /* If the help window is not opened or if it already points to the - * correct location list, then free the new location list. */ + // If the help window is not opened or if it already points to the + // correct location list, then free the new location list. if (!bt_help(curwin->w_buffer) || curwin->w_llist == qi) { if (new_qi) { ll_free_all(&qi); diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 83ef3c2fce..597be0aa89 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3315,6 +3315,20 @@ func Test_qfjump() call Xqfjump_tests('l') endfunc +" Test helpgrep with lang specifier +func Xtest_helpgrep_with_lang_specifier(cchar) + call s:setup_commands(a:cchar) + Xhelpgrep Vim@en + call assert_equal('help', &filetype) + call assert_notequal(0, g:Xgetlist({'nr' : '$'}).nr) + new | only +endfunc + +func Test_helpgrep_with_lang_specifier() + call Xtest_helpgrep_with_lang_specifier('c') + call Xtest_helpgrep_with_lang_specifier('l') +endfunc + " The following test used to crash Vim. " Open the location list window and close the regular window associated with " the location list. When the garbage collection runs now, it incorrectly |