Skip to content

Commit 648ec8d

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents b9818a9 + c10f0e7 commit 648ec8d

File tree

8 files changed

+183
-87
lines changed

8 files changed

+183
-87
lines changed

runtime/doc/eval.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5848,9 +5848,13 @@ mode([expr]) Return a string that indicates the current mode.
58485848
S Select by line
58495849
CTRL-S Select blockwise
58505850
i Insert
5851+
ic Insert mode completion |compl-generic|
5852+
ix Insert mode |i_CTRL-X| completion
58515853
R Replace |R|
5854+
Rc Replace mode completion |compl-generic|
58525855
Rv Virtual Replace |gR|
5853-
c Command-line
5856+
Rx Replace mode |i_CTRL-X| completion
5857+
c Command-line editing
58545858
cv Vim Ex mode |gQ|
58555859
ce Normal Ex mode |Q|
58565860
r Hit-enter prompt

src/evalfunc.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7802,21 +7802,26 @@ f_mode(typval_T *argvars, typval_T *rettv)
78027802
}
78037803
else
78047804
#endif
7805-
if (State & REPLACE_FLAG)
7806-
buf[0] = 'R';
7807-
else
7808-
buf[0] = 'i';
7805+
{
7806+
if (State & REPLACE_FLAG)
7807+
buf[0] = 'R';
7808+
else
7809+
buf[0] = 'i';
7810+
#ifdef FEAT_INS_EXPAND
7811+
if (ins_compl_active())
7812+
buf[1] = 'c';
7813+
else if (ctrl_x_mode == 1)
7814+
buf[1] = 'x';
7815+
#endif
7816+
}
78097817
}
7810-
else if (State & CMDLINE)
7818+
else if ((State & CMDLINE) || exmode_active)
78117819
{
78127820
buf[0] = 'c';
7813-
if (exmode_active)
7821+
if (exmode_active == EXMODE_VIM)
78147822
buf[1] = 'v';
7815-
}
7816-
else if (exmode_active)
7817-
{
7818-
buf[0] = 'c';
7819-
buf[1] = 'e';
7823+
else if (exmode_active == EXMODE_NORMAL)
7824+
buf[1] = 'e';
78207825
}
78217826
else
78227827
{

src/screen.c

Lines changed: 55 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,57 @@ update_screen(int type)
777777
#endif
778778
}
779779

780+
#if defined(FEAT_SIGNS) || defined(FEAT_GUI) || defined(FEAT_CONCEAL)
781+
/*
782+
* Prepare for updating one or more windows.
783+
* Caller must check for "updating_screen" already set to avoid recursiveness.
784+
*/
785+
static void
786+
update_prepare(void)
787+
{
788+
cursor_off();
789+
updating_screen = TRUE;
790+
#ifdef FEAT_GUI
791+
/* Remove the cursor before starting to do anything, because scrolling may
792+
* make it difficult to redraw the text under it. */
793+
if (gui.in_use)
794+
gui_undraw_cursor();
795+
#endif
796+
#ifdef FEAT_SEARCH_EXTRA
797+
start_search_hl();
798+
#endif
799+
}
800+
801+
/*
802+
* Finish updating one or more windows.
803+
*/
804+
static void
805+
update_finish(void)
806+
{
807+
if (redraw_cmdline)
808+
showmode();
809+
810+
# ifdef FEAT_SEARCH_EXTRA
811+
end_search_hl();
812+
# endif
813+
814+
updating_screen = FALSE;
815+
816+
# ifdef FEAT_GUI
817+
gui_may_resize_shell();
818+
819+
/* Redraw the cursor and update the scrollbars when all screen updating is
820+
* done. */
821+
if (gui.in_use)
822+
{
823+
out_flush(); /* required before updating the cursor */
824+
gui_update_cursor(FALSE, FALSE);
825+
gui_update_scrollbars(FALSE);
826+
}
827+
# endif
828+
}
829+
#endif
830+
780831
#if defined(FEAT_CONCEAL) || defined(PROTO)
781832
/*
782833
* Return TRUE if the cursor line in window "wp" may be concealed, according
@@ -826,17 +877,12 @@ update_single_line(win_T *wp, linenr_T lnum)
826877
/* Don't do anything if the screen structures are (not yet) valid. */
827878
if (!screen_valid(TRUE) || updating_screen)
828879
return;
829-
updating_screen = TRUE;
830880

831881
if (lnum >= wp->w_topline && lnum < wp->w_botline
832882
&& foldedCount(wp, lnum, &win_foldinfo) == 0)
833883
{
834-
# ifdef FEAT_GUI
835-
/* Remove the cursor before starting to do anything, because scrolling
836-
* may make it difficult to redraw the text under it. */
837-
if (gui.in_use)
838-
gui_undraw_cursor();
839-
# endif
884+
update_prepare();
885+
840886
row = 0;
841887
for (j = 0; j < wp->w_lines_valid; ++j)
842888
{
@@ -856,68 +902,10 @@ update_single_line(win_T *wp, linenr_T lnum)
856902
}
857903
row += wp->w_lines[j].wl_size;
858904
}
859-
# ifdef FEAT_GUI
860-
/* Redraw the cursor */
861-
if (gui.in_use)
862-
{
863-
out_flush(); /* required before updating the cursor */
864-
gui_update_cursor(FALSE, FALSE);
865-
}
866-
# endif
867-
}
868-
need_cursor_line_redraw = FALSE;
869-
updating_screen = FALSE;
870-
}
871-
#endif
872-
873-
#if defined(FEAT_SIGNS) || defined(FEAT_GUI)
874-
/*
875-
* Prepare for updating one or more windows.
876-
* Caller must check for "updating_screen" already set to avoid recursiveness.
877-
*/
878-
static void
879-
update_prepare(void)
880-
{
881-
cursor_off();
882-
updating_screen = TRUE;
883-
#ifdef FEAT_GUI
884-
/* Remove the cursor before starting to do anything, because scrolling may
885-
* make it difficult to redraw the text under it. */
886-
if (gui.in_use)
887-
gui_undraw_cursor();
888-
#endif
889-
#ifdef FEAT_SEARCH_EXTRA
890-
start_search_hl();
891-
#endif
892-
}
893-
894-
/*
895-
* Finish updating one or more windows.
896-
*/
897-
static void
898-
update_finish(void)
899-
{
900-
if (redraw_cmdline)
901-
showmode();
902-
903-
# ifdef FEAT_SEARCH_EXTRA
904-
end_search_hl();
905-
# endif
906905

907-
updating_screen = FALSE;
908-
909-
# ifdef FEAT_GUI
910-
gui_may_resize_shell();
911-
912-
/* Redraw the cursor and update the scrollbars when all screen updating is
913-
* done. */
914-
if (gui.in_use)
915-
{
916-
out_flush(); /* required before updating the cursor */
917-
gui_update_cursor(FALSE, FALSE);
918-
gui_update_scrollbars(FALSE);
906+
update_finish();
919907
}
920-
# endif
908+
need_cursor_line_redraw = FALSE;
921909
}
922910
#endif
923911

src/testdir/runtest.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,13 @@ endif
153153

154154
" Names of flaky tests.
155155
let s:flaky = [
156-
\ 'Test_reltime()',
157-
\ 'Test_nb_basic()',
158-
\ 'Test_communicate()',
159156
\ 'Test_close_and_exit_cb()',
157+
\ 'Test_collapse_buffers()',
158+
\ 'Test_communicate()',
159+
\ 'Test_nb_basic()',
160160
\ 'Test_pipe_through_sort_all()',
161161
\ 'Test_pipe_through_sort_some()'
162+
\ 'Test_reltime()',
162163
\ ]
163164

164165
" Locate Test_ functions and execute them.

src/testdir/test_functions.vim

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,89 @@ func Test_toupper()
304304
call assert_equal("Ⱥ Ⱦ", toupper("ⱥ ⱦ"))
305305
endfunc
306306

307+
" Tests for the mode() function
308+
let current_modes = ''
309+
func! Save_mode()
310+
let g:current_modes = mode(0) . '-' . mode(1)
311+
return ''
312+
endfunc
307313

314+
func! Test_mode()
315+
new
316+
call append(0, ["Blue Ball Black", "Brown Band Bowl", ""])
317+
318+
inoremap <F2> <C-R>=Save_mode()<CR>
319+
320+
normal! 3G
321+
exe "normal i\<F2>\<Esc>"
322+
call assert_equal('i-i', g:current_modes)
323+
exe "normal i\<C-G>uBa\<C-P>\<F2>\<Esc>u"
324+
call assert_equal('i-ic', g:current_modes)
325+
exe "normal iBro\<C-P>\<F2>\<Esc>u"
326+
call assert_equal('i-ic', g:current_modes)
327+
exe "normal iBa\<C-X>\<F2>\<Esc>u"
328+
call assert_equal('i-ix', g:current_modes)
329+
exe "normal iBa\<C-X>\<C-P>\<F2>\<Esc>u"
330+
call assert_equal('i-ic', g:current_modes)
331+
exe "normal iBro\<C-X>\<C-P>\<F2>\<Esc>u"
332+
call assert_equal('i-ic', g:current_modes)
333+
exe "normal iBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
334+
call assert_equal('i-ic', g:current_modes)
335+
exe "normal iCom\<C-P>\<F2>\<Esc>u"
336+
call assert_equal('i-ic', g:current_modes)
337+
exe "normal iCom\<C-X>\<C-P>\<F2>\<Esc>u"
338+
call assert_equal('i-ic', g:current_modes)
339+
340+
exe "normal RBa\<C-P>\<F2>\<Esc>u"
341+
call assert_equal('R-Rc', g:current_modes)
342+
exe "normal RBro\<C-P>\<F2>\<Esc>u"
343+
call assert_equal('R-Rc', g:current_modes)
344+
exe "normal RBa\<C-X>\<F2>\<Esc>u"
345+
call assert_equal('R-Rx', g:current_modes)
346+
exe "normal RBa\<C-X>\<C-P>\<F2>\<Esc>u"
347+
call assert_equal('R-Rc', g:current_modes)
348+
exe "normal RBro\<C-X>\<C-P>\<F2>\<Esc>u"
349+
call assert_equal('R-Rc', g:current_modes)
350+
exe "normal RBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
351+
call assert_equal('R-Rc', g:current_modes)
352+
exe "normal RCom\<C-P>\<F2>\<Esc>u"
353+
call assert_equal('R-Rc', g:current_modes)
354+
exe "normal RCom\<C-X>\<C-P>\<F2>\<Esc>u"
355+
call assert_equal('R-Rc', g:current_modes)
356+
357+
call assert_equal('n', mode(0))
358+
call assert_equal('n', mode(1))
359+
360+
" How to test operator-pending mode?
361+
362+
call feedkeys("v", 'xt')
363+
call assert_equal('v', mode())
364+
call assert_equal('v', mode(1))
365+
call feedkeys("\<Esc>V", 'xt')
366+
call assert_equal('V', mode())
367+
call assert_equal('V', mode(1))
368+
call feedkeys("\<Esc>\<C-V>", 'xt')
369+
call assert_equal("\<C-V>", mode())
370+
call assert_equal("\<C-V>", mode(1))
371+
call feedkeys("\<Esc>", 'xt')
372+
373+
call feedkeys("gh", 'xt')
374+
call assert_equal('s', mode())
375+
call assert_equal('s', mode(1))
376+
call feedkeys("\<Esc>gH", 'xt')
377+
call assert_equal('S', mode())
378+
call assert_equal('S', mode(1))
379+
call feedkeys("\<Esc>g\<C-H>", 'xt')
380+
call assert_equal("\<C-S>", mode())
381+
call assert_equal("\<C-S>", mode(1))
382+
call feedkeys("\<Esc>", 'xt')
383+
384+
call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt')
385+
call assert_equal('c-c', g:current_modes)
386+
call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt')
387+
call assert_equal('c-cv', g:current_modes)
388+
" How to test Ex mode?
389+
390+
bwipe!
391+
iunmap <F2>
392+
endfunc

src/testdir/test_mapping.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ func Test_map_langmap()
110110
call feedkeys(":call append(line('$'), '+')\<CR>", "xt")
111111
call assert_equal('+', getline('$'))
112112

113+
iunmap a
114+
iunmap c
113115
set nomodified
114116
endfunc
115117

@@ -120,7 +122,7 @@ func Test_map_feedkeys()
120122
$-1
121123
call feedkeys("0qqdw.ifoo\<Esc>qj0@q\<Esc>", "xt")
122124
call assert_equal(['fooc d', 'fooc d'], getline(line('$') - 1, line('$')))
123-
unmap .
125+
nunmap .
124126
set nomodified
125127
endfunc
126128

src/testdir/unix.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
" Always use "sh", don't use the value of "$SHELL".
33
set shell=sh
44

5-
" While some tests overwrite $HOME to prevent them from polluting user files,
6-
" we need to remember the original value so that we can tell external systems
7-
" where to ask about their own user settings.
8-
let g:tester_HOME = $HOME
5+
" Only when the +eval feature is present.
6+
if 1
7+
" While some tests overwrite $HOME to prevent them from polluting user files,
8+
" we need to remember the original value so that we can tell external systems
9+
" where to ask about their own user settings.
10+
let g:tester_HOME = $HOME
11+
endif
912

1013
source setup.vim

src/version.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
286,
784+
/**/
785+
285,
786+
/**/
787+
284,
788+
/**/
789+
283,
782790
/**/
783791
282,
784792
/**/

0 commit comments

Comments
 (0)