diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2016-12-10 17:02:02 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-12-26 22:21:14 +0100 |
commit | 4431975210b58c6b0403ee50172bad3c8729bbb2 (patch) | |
tree | 568788b07faa6ebab59e0dfcf56f11fbbe0c6985 /src | |
parent | e9a2f77bff013345e3114dc9189ae8ce456b0622 (diff) | |
download | rneovim-4431975210b58c6b0403ee50172bad3c8729bbb2.tar.gz rneovim-4431975210b58c6b0403ee50172bad3c8729bbb2.tar.bz2 rneovim-4431975210b58c6b0403ee50172bad3c8729bbb2.zip |
vim-patch:0 completion-related patches #5745 #5829
vim-patch:8.0.0058
Problem: Positioning of the popup menu is not good.
Solution: Position it better. (Hirohito Higashi)
https://github.com/vim/vim/commit/91e44a3305ef6bf2d43496c351dcff0a45c6bfb8
vim-patch:8.0.0099
Problem: Popup menu always appears above the cursor when it is in the lower
half of the screen. (Matt Gardner)
Solution: Compute the available space better. (Hirohito Higashi,
closes vim/vim#1241)
https://github.com/vim/vim/commit/73095288da839f7c738a49baa109773e76106806
vim-patch:8.0.0127
Problem: Cancelling completion still inserts text when formatting is done
for 'textwidth'. (lacygoill)
Solution: Don't format when CTRL-E was typed. (Hirohito Higashi,
closes vim/vim#1312)
https://github.com/vim/vim/commit/73fd4988866c3adc15b5d093efdf5e8cf70d093d
vim-patch:7.4.2188
Problem: Completion does not work properly with some plugins.
Solution: Revert the part related to typing CTRL-E. (closes vim/vim#972)
https://github.com/vim/vim/commit/c9fb77c69244870a97384152f20845665c19fe39
vim-patch:7.4.2146
Problem: Not enough testing for popup menu. CTRL-E does not always work
properly.
Solution: Add more tests. When using CTRL-E check if the popup menu is
visible. (Christian Brabandt)
https://github.com/vim/vim/commit/472472898ab71ac80a86fedc37f8eb91461788dd
vim-patch:7.4.2147
Problem: test_alot fails.
Solution: Close window.
https://github.com/vim/vim/commit/abb71fbd399772d467aaa7b34b958b0f975c7e65
vim-patch:7.4.2149
Problem: If a test leaves a window open a following test may fail.
Solution: Always close extra windows after running a test.
https://github.com/vim/vim/commit/7cba71d7e3576639679b6a3aedeeb1ac07f7f2f5
vim-patch:7.4.2321
Problem: When a test is commented out we forget about it.
Solution: Let a test throw an exception with "Skipped" and list skipped test
functions. (Christian Brabandt)
https://github.com/vim/vim/commit/dac1947bb366ef43cd6da95acc730554e76d8b84
vim-patch:7.4.2331
Problem: Using CTRL-X CTRL-V to complete a command line from Insert mode
does not work after entering an expression on the command line.
Solution: Don't use "ccline" when not actually using a command line. (test
by Hirohito Higashi)
https://github.com/vim/vim/commit/33a80eeb859a78ba93432da6fa585786cfd77249
vim-patch:8.0.0008
Problem: Popup complete test is disabled.
Solution: Enable the test and change the assert. (Hirohito Higashi)
https://github.com/vim/vim/commit/9e02cfa226b2577ec867b544a1a450a428a19880
vim-patch:8.0.0047
Problem: Crash when using the preview window from an unnamed buffer.
(lifepillar)
Solution: Do not clear the wrong buffer. (closes vim/vim#1200)
https://github.com/vim/vim/commit/50e5376926dc2ec4a26a7a16f8f0f3213c4afdf0
vim-patch:8.0.0053
Problem: No test for what 8.0.0047 fixes.
Solution: Add a test. (Hirohito Higashi)
https://github.com/vim/vim/commit/60ef3e81f4a54d9f7ee617d57021f0811ec8ada5
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/edit.c | 16 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 15 | ||||
-rw-r--r-- | src/nvim/globals.h | 1 | ||||
-rw-r--r-- | src/nvim/popupmnu.c | 48 | ||||
-rw-r--r-- | src/nvim/testdir/runtest.vim | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 381 | ||||
-rw-r--r-- | src/nvim/version.c | 12 |
7 files changed, 402 insertions, 80 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 164194f5a7..7e917336e5 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3267,7 +3267,7 @@ static bool ins_compl_prep(int c) dec_cursor(); } - if (!arrow_used && !ins_need_undo) { + if (!arrow_used && !ins_need_undo && c != Ctrl_E) { insertchar(NUL, 0, -1); } @@ -3286,7 +3286,8 @@ static bool ins_compl_prep(int c) retval = true; } - /* CTRL-E means completion is Ended, go back to the typed text. */ + // CTRL-E means completion is Ended, go back to the typed text. + // but only do this, if the Popup is still visible if (c == Ctrl_E) { ins_compl_delete(); if (compl_leader != NULL) { @@ -4516,14 +4517,15 @@ static int ins_complete(int c, bool enable_pum) } else if (ctrl_x_mode == CTRL_X_CMDLINE) { compl_pattern = vim_strnsave(line, curs_col); set_cmd_context(&compl_xp, compl_pattern, - (int)STRLEN(compl_pattern), curs_col); + (int)STRLEN(compl_pattern), curs_col, false); if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL - || compl_xp.xp_context == EXPAND_NOTHING) - /* No completion possible, use an empty pattern to get a - * "pattern not found" message. */ + || compl_xp.xp_context == EXPAND_NOTHING) { + // No completion possible, use an empty pattern to get a + // "pattern not found" message. compl_col = curs_col; - else + } else { compl_col = (int)(compl_xp.xp_pattern - compl_pattern); + } compl_length = curs_col - compl_col; } else if (ctrl_x_mode == CTRL_X_FUNCTION || ctrl_x_mode == CTRL_X_OMNI) { diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 532775ad0b..7c725179dd 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3613,15 +3613,16 @@ static void set_expand_context(expand_T *xp) xp->xp_context = EXPAND_NOTHING; return; } - set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos); + set_cmd_context(xp, ccline.cmdbuff, ccline.cmdlen, ccline.cmdpos, true); } void set_cmd_context ( expand_T *xp, - char_u *str, /* start of command line */ - int len, /* length of command line (excl. NUL) */ - int col /* position of cursor */ + char_u *str, // start of command line + int len, // length of command line (excl. NUL) + int col, // position of cursor + int use_ccline // use ccline for info ) { int old_char = NUL; @@ -3636,10 +3637,10 @@ set_cmd_context ( str[col] = NUL; nextcomm = str; - if (ccline.cmdfirstc == '=') { - /* pass CMD_SIZE because there is no real command */ + if (use_ccline && ccline.cmdfirstc == '=') { + // pass CMD_SIZE because there is no real command set_context_for_expression(xp, str, CMD_SIZE); - } else if (ccline.input_fn) { + } else if (use_ccline && ccline.input_fn) { xp->xp_context = ccline.xp_context; xp->xp_pattern = ccline.cmdbuff; xp->xp_arg = ccline.xp_arg; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index f7edeed933..fbffc2d44d 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -570,6 +570,7 @@ EXTERN win_T *prevwin INIT(= NULL); /* previous window */ FOR_ALL_TABS(tp) \ FOR_ALL_WINDOWS_IN_TAB(wp, tp) +# define FOR_ALL_WINDOWS(wp) for (wp = firstwin; wp != NULL; wp = wp->w_next) # define FOR_ALL_WINDOWS_IN_TAB(wp, tp) \ for (win_T *wp = ((tp) == curtab) \ ? firstwin : (tp)->tp_firstwin; wp != NULL; wp = wp->w_next) diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 947814de4f..89180f76de 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -67,12 +67,13 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed) int kind_width; int extra_width; int i; - int top_clear; int row; int context_lines; int col; - int above_row = cmdline_row; + int above_row; + int below_row; int redo_count = 0; + win_T *pvwin; if (!pum_is_visible) { // To keep the code simple, we only allow changing the @@ -85,6 +86,8 @@ redo: // to avoid that must_redraw is set when 'cursorcolumn' is on. pum_is_visible = true; validate_cursor_col(); + above_row = 0; + below_row = cmdline_row; // anchor position: the start of the completed word row = curwin->w_wrow + curwin->w_winrow; @@ -123,17 +126,18 @@ redo: kind_width = 0; extra_width = 0; - if (firstwin->w_p_pvw) { - top_clear = firstwin->w_height; - } else { - top_clear = 0; + FOR_ALL_WINDOWS(pvwin) { + if (pvwin->w_p_pvw) { + break; + } } - // When the preview window is at the bottom stop just above it. Also - // avoid drawing over the status line so that it's clear there is a window - // boundary. - if (lastwin->w_p_pvw) { - above_row -= lastwin->w_height + lastwin->w_status_height + 1; + if (pvwin != NULL) { + if (pvwin->w_wrow < curwin->w_wrow) { + above_row = pvwin->w_wrow + pvwin->w_height; + } else if (pvwin->w_wrow > pvwin->w_wrow + curwin->w_height) { + below_row = pvwin->w_wrow; + } } // Figure out the size and position of the pum. @@ -149,8 +153,8 @@ redo: // Put the pum below "row" if possible. If there are few lines decide on // where there is more room. - if ((row + 2 >= above_row - pum_height) - && (row > (above_row - top_clear) / 2)) { + if (row + 2 >= below_row - pum_height + && row - above_row > (below_row - above_row) / 2) { // pum above "row" // Leave two lines of context if possible @@ -184,8 +188,8 @@ redo: } pum_row = row + context_lines; - if (size > above_row - pum_row) { - pum_height = above_row - pum_row; + if (size > below_row - pum_row) { + pum_height = below_row - pum_row; } else { pum_height = size; } @@ -200,12 +204,10 @@ redo: return; } - // If there is a preview window at the top avoid drawing over it. - if (firstwin->w_p_pvw - && (pum_row < firstwin->w_height) - && (pum_height > firstwin->w_height + 4)) { - pum_row += firstwin->w_height; - pum_height -= firstwin->w_height; + // If there is a preview window at the above avoid drawing over it. + if (pvwin != NULL && pum_row < above_row && pum_height > above_row) { + pum_row += above_row; + pum_height -= above_row; } // Compute the width of the widest match and the widest extra. @@ -588,7 +590,9 @@ static int pum_set_selected(int n, int repeat) g_do_tagpreview = 0; if (curwin->w_p_pvw) { - if ((curbuf->b_fname == NULL) + if (!resized + && (curbuf->b_nwindows == 1) + && (curbuf->b_fname == NULL) && (curbuf->b_p_bt[0] == 'n') && (curbuf->b_p_bt[2] == 'f') && (curbuf->b_p_bh[0] == 'w')) { diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index ac9774abc3..931013877d 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -76,6 +76,9 @@ function RunTheTest(test) let s:done += 1 try exe 'call ' . a:test + catch /^\cskipped/ + call add(s:messages, ' Skipped') + call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', '')) catch call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) endtry @@ -92,6 +95,7 @@ let s:done = 0 let s:fail = 0 let s:errors = [] let s:messages = [] +let s:skipped = [] if expand('%') =~ 'test_viml.vim' " this test has intentional s:errors, don't use try/catch. source % @@ -166,7 +170,10 @@ if s:fail > 0 call extend(s:messages, s:errors) endif -" Append messages to "messages" +" Add SKIPPED messages +call extend(s:messages, s:skipped) + +" Append messages to the file "messages" split messages call append(line('$'), '') call append(line('$'), 'From ' . g:testname . ':') diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 8615e32cfd..50110dd622 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -1,69 +1,294 @@ " Test for completion menu -function! ComplTest() abort - call complete(1, ['source', 'soundfold']) - return '' -endfunction +let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] +let g:setting = '' -function! Test() abort - call complete(1, ['source', 'soundfold']) +func! ListMonths() + if g:setting != '' + exe ":set" g:setting + endif + let mth=copy(g:months) + let entered = strcharpart(getline('.'),0,col('.')) + if !empty(entered) + let mth=filter(mth, 'v:val=~"^".entered') + endif + call complete(1, mth) return '' -endfunction +endfunc -func Test_noinsert_complete() +func! Test_popup_complete2() + " Although the popupmenu is not visible, this does not mean completion mode + " has ended. After pressing <f5> to complete the currently typed char, Vim + " still stays in the first state of the completion (:h ins-completion-menu), + " although the popupmenu wasn't shown <c-e> will remove the inserted + " completed text (:h complete_CTRL-E), while the following <c-e> will behave + " like expected (:h i_CTRL-E) new - set completeopt+=noinsert - inoremap <F5> <C-R>=ComplTest()<CR> - call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx') - call assert_equal('soundfold', getline(1)) - call assert_equal('soundfold', getline(2)) - bwipe! + inoremap <f5> <c-r>=ListMonths()<cr> + call append(1, ["December2015"]) + :1 + call feedkeys("aD\<f5>\<C-E>\<C-E>\<C-E>\<C-E>\<enter>\<esc>", 'tx') + call assert_equal(["Dece", "", "December2015"], getline(1,3)) + %d + bw! +endfu +func! Test_popup_complete() new - inoremap <F5> <C-R>=Test()<CR> - call feedkeys("i\<F5>\<CR>\<ESC>", 'tx') - call assert_equal('source', getline(1)) - bwipe! + inoremap <f5> <c-r>=ListMonths()<cr> - set completeopt-=noinsert - iunmap <F5> -endfunc + " <C-E> - select original typed text before the completion started + call feedkeys("aJu\<f5>\<down>\<c-e>\<esc>", 'tx') + call assert_equal(["Ju"], getline(1,2)) + %d -let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] -let g:setting = '' + " <C-Y> - accept current match + call feedkeys("a\<f5>". repeat("\<down>",7). "\<c-y>\<esc>", 'tx') + call assert_equal(["August"], getline(1,2)) + %d + + " <BS> - Delete one character from the inserted text (state: 1) + " TODO: This should not end the completion, but it does. + " This should according to the documentation: + " January + " but instead, this does + " Januar + " (idea is, C-L inserts the match from the popup menu + " but if the menu is closed, it will insert the character <c-l> + call feedkeys("aJ\<f5>\<bs>\<c-l>\<esc>", 'tx') + call assert_equal(["Januar"], getline(1,2)) + %d + + " any-non special character: Stop completion without changing the match + " and insert the typed character + call feedkeys("a\<f5>20", 'tx') + call assert_equal(["January20"], getline(1,2)) + %d + + " any-non printable, non-white character: Add this character and + " reduce number of matches + call feedkeys("aJu\<f5>\<c-p>l\<c-y>", 'tx') + call assert_equal(["Jul"], getline(1,2)) + %d + + " any-non printable, non-white character: Add this character and + " reduce number of matches + call feedkeys("aJu\<f5>\<c-p>l\<c-n>\<c-y>", 'tx') + call assert_equal(["July"], getline(1,2)) + %d + + " any-non printable, non-white character: Add this character and + " reduce number of matches + call feedkeys("aJu\<f5>\<c-p>l\<c-e>", 'tx') + call assert_equal(["Jul"], getline(1,2)) + %d + + " <BS> - Delete one character from the inserted text (state: 2) + call feedkeys("a\<f5>\<c-n>\<bs>", 'tx') + call assert_equal(["Februar"], getline(1,2)) + %d + + " <c-l> - Insert one character from the current match + call feedkeys("aJ\<f5>".repeat("\<c-n>",3)."\<c-l>\<esc>", 'tx') + call assert_equal(["J"], getline(1,2)) + %d + + " <c-l> - Insert one character from the current match + call feedkeys("aJ\<f5>".repeat("\<c-n>",4)."\<c-l>\<esc>", 'tx') + call assert_equal(["January"], getline(1,2)) + %d + + " <c-y> - Accept current selected match + call feedkeys("aJ\<f5>\<c-y>\<esc>", 'tx') + call assert_equal(["January"], getline(1,2)) + %d + + " <c-e> - End completion, go back to what was there before selecting a match + call feedkeys("aJu\<f5>\<c-e>\<esc>", 'tx') + call assert_equal(["Ju"], getline(1,2)) + %d + + " <PageUp> - Select a match several entries back + call feedkeys("a\<f5>\<PageUp>\<c-y>\<esc>", 'tx') + call assert_equal([""], getline(1,2)) + %d + + " <PageUp><PageUp> - Select a match several entries back + call feedkeys("a\<f5>\<PageUp>\<PageUp>\<c-y>\<esc>", 'tx') + call assert_equal(["December"], getline(1,2)) + %d + + " <PageUp><PageUp><PageUp> - Select a match several entries back + call feedkeys("a\<f5>\<PageUp>\<PageUp>\<PageUp>\<c-y>\<esc>", 'tx') + call assert_equal(["February"], getline(1,2)) + %d + + " <PageDown> - Select a match several entries further + call feedkeys("a\<f5>\<PageDown>\<c-y>\<esc>", 'tx') + call assert_equal(["November"], getline(1,2)) + %d + + " <PageDown><PageDown> - Select a match several entries further + call feedkeys("a\<f5>\<PageDown>\<PageDown>\<c-y>\<esc>", 'tx') + call assert_equal(["December"], getline(1,2)) + %d + + " <PageDown><PageDown><PageDown> - Select a match several entries further + call feedkeys("a\<f5>\<PageDown>\<PageDown>\<PageDown>\<c-y>\<esc>", 'tx') + call assert_equal([""], getline(1,2)) + %d + + " <PageDown><PageDown><PageDown><PageDown> - Select a match several entries further + call feedkeys("a\<f5>".repeat("\<PageDown>",4)."\<c-y>\<esc>", 'tx') + call assert_equal(["October"], getline(1,2)) + %d + + " <Up> - Select a match don't insert yet + call feedkeys("a\<f5>\<Up>\<c-y>\<esc>", 'tx') + call assert_equal([""], getline(1,2)) + %d + + " <Up><Up> - Select a match don't insert yet + call feedkeys("a\<f5>\<Up>\<Up>\<c-y>\<esc>", 'tx') + call assert_equal(["December"], getline(1,2)) + %d + + " <Up><Up><Up> - Select a match don't insert yet + call feedkeys("a\<f5>\<Up>\<Up>\<Up>\<c-y>\<esc>", 'tx') + call assert_equal(["November"], getline(1,2)) + %d + + " <Tab> - Stop completion and insert the match + call feedkeys("a\<f5>\<Tab>\<c-y>\<esc>", 'tx') + call assert_equal(["January "], getline(1,2)) + %d + + " <Space> - Stop completion and insert the match + call feedkeys("a\<f5>".repeat("\<c-p>",5)." \<esc>", 'tx') + call assert_equal(["September "], getline(1,2)) + %d + + " <Enter> - Use the text and insert line break (state: 1) + call feedkeys("a\<f5>\<enter>\<esc>", 'tx') + call assert_equal(["January", ''], getline(1,2)) + %d + + " <Enter> - Insert the current selected text (state: 2) + call feedkeys("a\<f5>".repeat("\<Up>",5)."\<enter>\<esc>", 'tx') + call assert_equal(["September"], getline(1,2)) + %d + + " Insert match immediately, if there is only one match + " <c-y> selects a character from the line above + call append(0, ["December2015"]) + call feedkeys("aD\<f5>\<C-Y>\<C-Y>\<C-Y>\<C-Y>\<enter>\<esc>", 'tx') + call assert_equal(["December2015", "December2015", ""], getline(1,3)) + %d + + " use menuone for 'completeopt' + " Since for the first <c-y> the menu is still shown, will only select + " three letters from the line above + set completeopt&vim + set completeopt+=menuone + call append(0, ["December2015"]) + call feedkeys("aD\<f5>\<C-Y>\<C-Y>\<C-Y>\<C-Y>\<enter>\<esc>", 'tx') + call assert_equal(["December2015", "December201", ""], getline(1,3)) + %d + + " use longest for 'completeopt' + set completeopt&vim + call feedkeys("aM\<f5>\<C-N>\<C-P>\<c-e>\<enter>\<esc>", 'tx') + set completeopt+=longest + call feedkeys("aM\<f5>\<C-N>\<C-P>\<c-e>\<enter>\<esc>", 'tx') + call assert_equal(["M", "Ma", ""], getline(1,3)) + %d + + " use noselect/noinsert for 'completeopt' + set completeopt&vim + call feedkeys("aM\<f5>\<enter>\<esc>", 'tx') + set completeopt+=noselect + call feedkeys("aM\<f5>\<enter>\<esc>", 'tx') + set completeopt-=noselect completeopt+=noinsert + call feedkeys("aM\<f5>\<enter>\<esc>", 'tx') + call assert_equal(["March", "M", "March"], getline(1,4)) + %d +endfu -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') + inoremap <F5> <C-R>=ListMonths()<CR> + + call feedkeys("a\<f5>\<down>\<enter>\<esc>", 'tx') call assert_equal('February', getline(1)) %d + " Set noinsertmode let g:setting = 'noinsertmode' - call feedkeys("a\<F5>\<down>\<enter>\<esc>", 'tx') + call feedkeys("a\<f5>\<down>\<enter>\<esc>", 'tx') call assert_equal('February', getline(1)) call assert_false(pumvisible()) %d + " Go through all matches, until none is selected let g:setting = '' - call feedkeys("a\<F5>". repeat("\<c-n>",12)."\<enter>\<esc>", 'tx') + 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') + " select previous entry + 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') + " select last entry + call feedkeys("a\<f5>\<c-p>\<c-p>\<enter>\<esc>", 'tx') call assert_equal('December', getline(1)) + + iunmap <F5> +endfunc + +func Test_noinsert_complete() + function! s:complTest1() abort + call complete(1, ['source', 'soundfold']) + return '' + endfunction + + function! s:complTest2() abort + call complete(1, ['source', 'soundfold']) + return '' + endfunction + + new + set completeopt+=noinsert + inoremap <F5> <C-R>=s:complTest1()<CR> + call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx') + call assert_equal('soundfold', getline(1)) + call assert_equal('soundfold', getline(2)) + bwipe! + + new + inoremap <F5> <C-R>=s:complTest2()<CR> + call feedkeys("i\<F5>\<CR>\<ESC>", 'tx') + call assert_equal('source', getline(1)) bwipe! + + set completeopt-=noinsert iunmap <F5> endfunc +func Test_compl_vim_cmds_after_register_expr() + function! s:test_func() + return 'autocmd ' + endfunction + augroup AAAAA_Group + au! + augroup END + + new + call feedkeys("i\<c-r>=s:test_func()\<CR>\<C-x>\<C-v>\<Esc>", 'tx') + call assert_equal('autocmd AAAAA_Group', getline(1)) + autocmd! AAAAA_Group + augroup! AAAAA_Group + bwipe! +endfunc + func DummyCompleteOne(findstart, base) if a:findstart return 0 @@ -153,7 +378,7 @@ func DummyCompleteFour(findstart, base) endif endfunc -:"Test that 'completefunc' works when it's OK. +" Test that 'omnifunc' works when it's OK. func Test_omnifunc_with_check() new setlocal omnifunc=DummyCompleteFour @@ -175,4 +400,86 @@ func Test_omnifunc_with_check() q! endfunc +function UndoComplete() + call complete(1, ['January', 'February', 'March', + \ 'April', 'May', 'June', 'July', 'August', 'September', + \ 'October', 'November', 'December']) + return '' +endfunc + +" Test that no undo item is created when no completion is inserted +func Test_complete_no_undo() + set completeopt=menu,preview,noinsert,noselect + inoremap <Right> <C-R>=UndoComplete()<CR> + new + call feedkeys("ixxx\<CR>\<CR>yyy\<Esc>k", 'xt') + call feedkeys("iaaa\<Esc>0", 'xt') + call assert_equal('aaa', getline(2)) + call feedkeys("i\<Right>\<Esc>", 'xt') + call assert_equal('aaa', getline(2)) + call feedkeys("u", 'xt') + call assert_equal('', getline(2)) + + call feedkeys("ibbb\<Esc>0", 'xt') + call assert_equal('bbb', getline(2)) + call feedkeys("A\<Right>\<Down>\<CR>\<Esc>", 'xt') + call assert_equal('January', getline(2)) + call feedkeys("u", 'xt') + call assert_equal('bbb', getline(2)) + + call feedkeys("A\<Right>\<C-N>\<Esc>", 'xt') + call assert_equal('January', getline(2)) + call feedkeys("u", 'xt') + call assert_equal('bbb', getline(2)) + + iunmap <Right> + set completeopt& + q! +endfunc + +function! DummyCompleteFive(findstart, base) + if a:findstart + return 0 + else + return [ + \ { 'word': 'January', 'info': "info1-1\n1-2\n1-3" }, + \ { 'word': 'February', 'info': "info2-1\n2-2\n2-3" }, + \ { 'word': 'March', 'info': "info3-1\n3-2\n3-3" }, + \ { 'word': 'April', 'info': "info4-1\n4-2\n4-3" }, + \ { 'word': 'May', 'info': "info5-1\n5-2\n5-3" }, + \ ] + endif +endfunc + +" Test that 'completefunc' on Scratch buffer with preview window works when +" it's OK. +func Test_completefunc_with_scratch_buffer() + new +setlocal\ buftype=nofile\ bufhidden=wipe\ noswapfile + set completeopt+=preview + setlocal completefunc=DummyCompleteFive + call feedkeys("A\<C-X>\<C-U>\<C-N>\<C-N>\<C-N>\<Esc>", "x") + call assert_equal(['April'], getline(1, '$')) + pclose + q! + set completeopt& +endfunc + +" <C-E> - select original typed text before the completion started without +" auto-wrap text. +func Test_completion_ctrl_e_without_autowrap() + new + let tw_save=&tw + set tw=78 + let li = [ + \ '" zzz', + \ '" zzzyyyyyyyyyyyyyyyyyyy'] + call setline(1, li) + 0 + call feedkeys("A\<C-X>\<C-N>\<C-E>\<Esc>", "tx") + call assert_equal(li, getline(1, '$')) + + let &tw=tw_save + q! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 220e0fc7af..72b39ba974 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -109,7 +109,7 @@ static int included_patches[] = { // 2334, // 2333, // 2332 NA - // 2331, + 2331, // 2330, // 2329, // 2328, @@ -119,7 +119,7 @@ static int included_patches[] = { // 2324, // 2323, // 2322, - // 2321, + 2321, // 2320, // 2319 NA // 2318, @@ -252,7 +252,7 @@ static int included_patches[] = { // 2191 NA // 2190, // 2189, - // 2188, + 2188, // 2187, // 2186 NA // 2185, @@ -291,10 +291,10 @@ static int included_patches[] = { // 2152, // 2151, // 2150 NA - // 2149, + 2149, // 2148, - // 2147, - // 2146, + 2147, + 2146, // 2145 NA // 2144, // 2143, |