aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/ex_getln.c62
-rw-r--r--src/nvim/option.c18
-rw-r--r--src/nvim/testdir/test_help_tagjump.vim115
-rw-r--r--src/nvim/testdir/test_popup.vim35
-rw-r--r--src/nvim/version.c10
6 files changed, 210 insertions, 32 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 18d5ea533d..ca5b6f02ce 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -502,7 +502,7 @@ static int insert_check(VimState *state)
Insstart_orig = Insstart;
}
- if (stop_insert_mode) {
+ if (stop_insert_mode && !pum_visible()) {
// ":stopinsert" used or 'insertmode' reset
s->count = 0;
return 0; // exit insert mode
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 1a97dc3d6f..4c997844ea 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2548,10 +2548,9 @@ static void cmdline_del(int from)
ccline.cmdpos = from;
}
-/*
- * this function is called when the screen size changes and with incremental
- * search
- */
+// This function is called when the screen size changes and with incremental
+// search and in other situations where the command line may have been
+// overwritten.
void redrawcmdline(void)
{
if (cmd_silent)
@@ -3669,27 +3668,54 @@ expand_cmdline (
return EXPAND_OK;
}
-/*
- * Cleanup matches for help tags: remove "@en" if "en" is the only language.
- */
-
+// Cleanup matches for help tags:
+// Remove "@ab" if the top of 'helplang' is "ab" and the language of the first
+// tag matches it. Otherwise remove "@en" if "en" is the only language.
static void cleanup_help_tags(int num_file, char_u **file)
{
- int i, j;
- int len;
+ char_u buf[4];
+ char_u *p = buf;
+
+ if (p_hlg[0] != NUL && (p_hlg[0] != 'e' || p_hlg[1] != 'n')) {
+ *p++ = '@';
+ *p++ = p_hlg[0];
+ *p++ = p_hlg[1];
+ }
+ *p = NUL;
- for (i = 0; i < num_file; ++i) {
- len = (int)STRLEN(file[i]) - 3;
- if (len > 0 && STRCMP(file[i] + len, "@en") == 0) {
- /* Sorting on priority means the same item in another language may
- * be anywhere. Search all items for a match up to the "@en". */
- for (j = 0; j < num_file; ++j)
+ for (int i = 0; i < num_file; i++) {
+ int len = (int)STRLEN(file[i]) - 3;
+ if (len <= 0) {
+ continue;
+ }
+ if (STRCMP(file[i] + len, "@en") == 0) {
+ // Sorting on priority means the same item in another language may
+ // be anywhere. Search all items for a match up to the "@en".
+ int j;
+ for (j = 0; j < num_file; j++) {
if (j != i
&& (int)STRLEN(file[j]) == len + 3
- && STRNCMP(file[i], file[j], len + 1) == 0)
+ && STRNCMP(file[i], file[j], len + 1) == 0) {
break;
- if (j == num_file)
+ }
+ }
+ if (j == num_file) {
+ // item only exists with @en, remove it
+ file[i][len] = NUL;
+ }
+ }
+ }
+
+ if (*buf != NUL) {
+ for (int i = 0; i < num_file; i++) {
+ int len = (int)STRLEN(file[i]) - 3;
+ if (len <= 0) {
+ continue;
+ }
+ if (STRCMP(file[i] + len, buf) == 0) {
+ // remove the default language
file[i][len] = NUL;
+ }
}
}
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 89889aa997..e2a5d38bee 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -3658,14 +3658,16 @@ set_bool_option (
/* when 'insertmode' is set from an autocommand need to do work here */
else if ((int *)varp == &p_im) {
if (p_im) {
- if ((State & INSERT) == 0)
- need_start_insertmode = TRUE;
- stop_insert_mode = FALSE;
- } else {
- need_start_insertmode = FALSE;
- stop_insert_mode = TRUE;
- if (restart_edit != 0 && mode_displayed)
- clear_cmdline = TRUE; /* remove "(insert)" */
+ if ((State & INSERT) == 0) {
+ need_start_insertmode = true;
+ }
+ stop_insert_mode = false;
+ } else if (old_value) { // only reset if it was set previously
+ need_start_insertmode = false;
+ stop_insert_mode = true;
+ if (restart_edit != 0 && mode_displayed) {
+ clear_cmdline = true; // remove "(insert)"
+ }
restart_edit = 0;
}
}
diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim
index 42f8391aba..cc1c81c7f6 100644
--- a/src/nvim/testdir/test_help_tagjump.vim
+++ b/src/nvim/testdir/test_help_tagjump.vim
@@ -48,3 +48,118 @@ func Test_help_tagjump()
call assert_true(getline('.') =~ '\*{address}\*')
helpclose
endfunc
+
+let s:langs = ['en', 'ab', 'ja']
+
+func s:doc_config_setup()
+ let s:helpfile_save = &helpfile
+ let &helpfile="Xdir1/doc-en/doc/testdoc.txt"
+ let s:rtp_save = &rtp
+ let &rtp="Xdir1/doc-en"
+ if has('multi_lang')
+ let s:helplang_save=&helplang
+ endif
+
+ call delete('Xdir1', 'rf')
+
+ for lang in s:langs
+ if lang ==# 'en'
+ let tagfname = 'tags'
+ let docfname = 'testdoc.txt'
+ else
+ let tagfname = 'tags-' . lang
+ let docfname = 'testdoc.' . lang . 'x'
+ endif
+ let docdir = "Xdir1/doc-" . lang . "/doc"
+ call mkdir(docdir, "p")
+ call writefile(["\t*test-char*", "\t*test-col*"], docdir . '/' . docfname)
+ call writefile(["test-char\t" . docfname . "\t/*test-char*",
+ \ "test-col\t" . docfname . "\t/*test-col*"],
+ \ docdir . '/' . tagfname)
+ endfor
+endfunc
+
+func s:doc_config_teardown()
+ call delete('Xdir1', 'rf')
+
+ let &helpfile = s:helpfile_save
+ let &rtp = s:rtp_save
+ if has('multi_lang')
+ let &helplang = s:helplang_save
+ endif
+endfunc
+
+func s:get_cmd_compl_list(cmd)
+ let list = []
+ let str = ''
+ for cnt in range(1, 999)
+ call feedkeys(a:cmd . repeat("\<Tab>", cnt) . "'\<C-B>let str='\<CR>", 'tx')
+ if str ==# a:cmd[1:]
+ break
+ endif
+ call add(list, str)
+ endfor
+ return list
+endfunc
+
+func Test_help_complete()
+ try
+ let list = []
+ call s:doc_config_setup()
+
+ " 'helplang=' and help file lang is 'en'
+ if has('multi_lang')
+ set helplang=
+ endif
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col', 'h test-char'], list)
+
+ if has('multi_lang')
+ " 'helplang=ab' and help file lang is 'en'
+ set helplang=ab
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(['h test-col', 'h test-char'], list)
+
+ " 'helplang=' and help file lang is 'en' and 'ab'
+ set rtp+=Xdir1/doc-ab
+ set helplang=
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(sort(['h test-col@en', 'h test-col@ab',
+ \ 'h test-char@en', 'h test-char@ab']), sort(list))
+
+ " 'helplang=ab' and help file lang is 'en' and 'ab'
+ set helplang=ab
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(sort(['h test-col', 'h test-col@en',
+ \ 'h test-char', 'h test-char@en']), sort(list))
+
+ " 'helplang=' and help file lang is 'en', 'ab' and 'ja'
+ set rtp+=Xdir1/doc-ja
+ set helplang=
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(sort(['h test-col@en', 'h test-col@ab',
+ \ 'h test-col@ja', 'h test-char@en',
+ \ 'h test-char@ab', 'h test-char@ja']), sort(list))
+
+ " 'helplang=ab' and help file lang is 'en', 'ab' and 'ja'
+ set helplang=ab
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(sort(['h test-col', 'h test-col@en',
+ \ 'h test-col@ja', 'h test-char',
+ \ 'h test-char@en', 'h test-char@ja']), sort(list))
+
+ " 'helplang=ab,ja' and help file lang is 'en', 'ab' and 'ja'
+ set helplang=ab,ja
+ let list = s:get_cmd_compl_list(":h test")
+ call assert_equal(sort(['h test-col', 'h test-col@ja',
+ \ 'h test-col@en', 'h test-char',
+ \ 'h test-char@ja', 'h test-char@en']), sort(list))
+ endif
+ catch
+ call assert_exception('X')
+ finally
+ call s:doc_config_teardown()
+ endtry
+endfunc
+
+" vim: et sw=2:
diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim
index 78fc81e3d2..63be8bf609 100644
--- a/src/nvim/testdir/test_popup.vim
+++ b/src/nvim/testdir/test_popup.vim
@@ -28,3 +28,38 @@ func Test_noinsert_complete()
set completeopt-=noinsert
iunmap <F5>
endfunc
+
+let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
+let g:setting = ''
+
+func ListMonths()
+ if g:setting != ''
+ exe ":set" g:setting
+ endif
+ call complete(col('.'), g:months)
+ return ''
+endfunc
+
+func! Test_popup_completion_insertmode()
+ inoremap <F5> <C-R>=ListMonths()<CR>
+ new
+ call feedkeys("a\<F5>\<down>\<enter>\<esc>", 'tx')
+ call assert_equal('February', getline(1))
+ %d
+ let g:setting = 'noinsertmode'
+ call feedkeys("a\<F5>\<down>\<enter>\<esc>", 'tx')
+ call assert_equal('February', getline(1))
+ call assert_false(pumvisible())
+ %d
+ let g:setting = ''
+ call feedkeys("a\<F5>". repeat("\<c-n>",12)."\<enter>\<esc>", 'tx')
+ call assert_equal('', getline(1))
+ %d
+ call feedkeys("a\<F5>\<c-p>\<enter>\<esc>", 'tx')
+ call assert_equal('', getline(1))
+ %d
+ call feedkeys("a\<F5>\<c-p>\<c-p>\<enter>\<esc>", 'tx')
+ call assert_equal('December', getline(1))
+ bwipe!
+ iunmap <F5>
+endfunc
diff --git a/src/nvim/version.c b/src/nvim/version.c
index dc5e313579..3f11c7e860 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -480,7 +480,7 @@ static int included_patches[] = {
// 1964,
// 1963 NA
// 1962,
- // 1961,
+ 1961,
1960,
// 1959 NA
// 1958 NA
@@ -620,10 +620,10 @@ static int included_patches[] = {
// 1824 NA
// 1823,
// 1822 NA
- // 1821,
- // 1820,
+ 1821,
+ 1820,
// 1819 NA
- // 1818,
+ 1818,
// 1817 NA
// 1816,
// 1815,
@@ -772,7 +772,7 @@ static int included_patches[] = {
// 1674 NA
1673,
// 1672 NA
- // 1671,
+ 1671,
1670,
// 1669 NA
// 1668 NA