mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 15:08:35 +00:00
vim-patch:8.0.0116
Problem: When reading English help and using CTRl-] the language from
'helplang' is used.
Solution: Make help tag jumps keep the language. (Tatsuki, test by Hirohito
Higashi, closes vim/vim#1249)
6dbf66aa3e
This commit is contained in:
@@ -1135,6 +1135,7 @@ find_tags (
|
|||||||
char_u *help_lang_find = NULL; /* lang to be found */
|
char_u *help_lang_find = NULL; /* lang to be found */
|
||||||
char_u help_lang[3]; /* lang of current tags file */
|
char_u help_lang[3]; /* lang of current tags file */
|
||||||
char_u *saved_pat = NULL; /* copy of pat[] */
|
char_u *saved_pat = NULL; /* copy of pat[] */
|
||||||
|
bool is_txt = false;
|
||||||
|
|
||||||
pat_T orgpat; /* holds unconverted pattern info */
|
pat_T orgpat; /* holds unconverted pattern info */
|
||||||
vimconv_T vimconv;
|
vimconv_T vimconv;
|
||||||
@@ -1232,6 +1233,14 @@ find_tags (
|
|||||||
* When the tag file is case-fold sorted, it is either one or the other.
|
* When the tag file is case-fold sorted, it is either one or the other.
|
||||||
* Only ignore case when TAG_NOIC not used or 'ignorecase' set.
|
* Only ignore case when TAG_NOIC not used or 'ignorecase' set.
|
||||||
*/
|
*/
|
||||||
|
// Set a flag if the file extension is .txt
|
||||||
|
if ((flags & TAG_KEEP_LANG)
|
||||||
|
&& help_lang_find == NULL
|
||||||
|
&& curbuf->b_fname != NULL
|
||||||
|
&& (i = (int)STRLEN(curbuf->b_fname)) > 4
|
||||||
|
&& STRICMP(curbuf->b_fname + i - 4, ".txt") == 0) {
|
||||||
|
is_txt = true;
|
||||||
|
}
|
||||||
orgpat.regmatch.rm_ic = ((p_ic || !noic)
|
orgpat.regmatch.rm_ic = ((p_ic || !noic)
|
||||||
&& (findall || orgpat.headlen == 0 || !p_tbs));
|
&& (findall || orgpat.headlen == 0 || !p_tbs));
|
||||||
for (round = 1; round <= 2; ++round) {
|
for (round = 1; round <= 2; ++round) {
|
||||||
@@ -1247,6 +1256,10 @@ find_tags (
|
|||||||
fp = NULL; // avoid GCC warning
|
fp = NULL; // avoid GCC warning
|
||||||
} else {
|
} else {
|
||||||
if (curbuf->b_help) {
|
if (curbuf->b_help) {
|
||||||
|
// Keep en if the file extension is .txt
|
||||||
|
if (is_txt) {
|
||||||
|
STRCPY(help_lang, "en");
|
||||||
|
} else {
|
||||||
/* Prefer help tags according to 'helplang'. Put the
|
/* Prefer help tags according to 'helplang'. Put the
|
||||||
* two-letter language name in help_lang[]. */
|
* two-letter language name in help_lang[]. */
|
||||||
i = (int)STRLEN(tag_fname);
|
i = (int)STRLEN(tag_fname);
|
||||||
@@ -1254,6 +1267,7 @@ find_tags (
|
|||||||
STRCPY(help_lang, tag_fname + i - 2);
|
STRCPY(help_lang, tag_fname + i - 2);
|
||||||
else
|
else
|
||||||
STRCPY(help_lang, "en");
|
STRCPY(help_lang, "en");
|
||||||
|
}
|
||||||
|
|
||||||
/* When searching for a specific language skip tags files
|
/* When searching for a specific language skip tags files
|
||||||
* for other languages. */
|
* for other languages. */
|
||||||
|
@@ -162,4 +162,36 @@ func Test_help_complete()
|
|||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_help_respect_current_file_lang()
|
||||||
|
try
|
||||||
|
let list = []
|
||||||
|
call s:doc_config_setup()
|
||||||
|
|
||||||
|
if has('multi_lang')
|
||||||
|
function s:check_help_file_ext(help_keyword, ext)
|
||||||
|
exec 'help ' . a:help_keyword
|
||||||
|
call assert_equal(a:ext, expand('%:e'))
|
||||||
|
call feedkeys("\<C-]>", 'tx')
|
||||||
|
call assert_equal(a:ext, expand('%:e'))
|
||||||
|
pop
|
||||||
|
helpclose
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
set rtp+=Xdir1/doc-ab
|
||||||
|
set rtp+=Xdir1/doc-ja
|
||||||
|
|
||||||
|
set helplang=ab
|
||||||
|
call s:check_help_file_ext('test-char', 'abx')
|
||||||
|
call s:check_help_file_ext('test-char@ja', 'jax')
|
||||||
|
set helplang=ab,ja
|
||||||
|
call s:check_help_file_ext('test-char@ja', 'jax')
|
||||||
|
call s:check_help_file_ext('test-char@en', 'txt')
|
||||||
|
endif
|
||||||
|
catch
|
||||||
|
call assert_exception('X')
|
||||||
|
finally
|
||||||
|
call s:doc_config_teardown()
|
||||||
|
endtry
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user