Merge branch 'master' into lsp-followup

This commit is contained in:
Ashkan Kiani
2019-11-24 01:22:16 -08:00
11 changed files with 117 additions and 71 deletions

View File

@@ -119,7 +119,7 @@ oldtest: | nvim build/runtime/doc/tags
ifeq ($(strip $(TEST_FILE)),) ifeq ($(strip $(TEST_FILE)),)
+$(SINGLE_MAKE) -C src/nvim/testdir NVIM_PRG="$(realpath build/bin/nvim)" $(MAKEOVERRIDES) +$(SINGLE_MAKE) -C src/nvim/testdir NVIM_PRG="$(realpath build/bin/nvim)" $(MAKEOVERRIDES)
else else
+$(SINGLE_MAKE) -C src/nvim/testdir NVIM_PRG="$(realpath build/bin/nvim)" NEW_TESTS=$(TEST_FILE) SCRIPTS= $(MAKEOVERRIDES) +$(SINGLE_MAKE) -C src/nvim/testdir NVIM_PRG="$(realpath build/bin/nvim)" SCRIPTS= $(MAKEOVERRIDES) $(TEST_FILE)
endif endif
build/runtime/doc/tags helptags: | nvim build/runtime/doc/tags helptags: | nvim

View File

@@ -1585,10 +1585,12 @@ void enter_buffer(buf_T *buf)
open_buffer(false, NULL, 0); open_buffer(false, NULL, 0);
} else { } else {
if (!msg_silent) { if (!msg_silent && !shortmess(SHM_FILEINFO)) {
need_fileinfo = true; // display file info after redraw need_fileinfo = true; // display file info after redraw
} }
(void)buf_check_timestamp(curbuf, false); // check if file changed // check if file changed
(void)buf_check_timestamp(curbuf, false);
curwin->w_topline = 1; curwin->w_topline = 1;
curwin->w_topfill = 0; curwin->w_topfill = 0;
apply_autocmds(EVENT_BUFENTER, NULL, NULL, false, curbuf); apply_autocmds(EVENT_BUFENTER, NULL, NULL, false, curbuf);

View File

@@ -3777,30 +3777,31 @@ find_prev_quote(
return col_start; return col_start;
} }
/* // Find quote under the cursor, cursor at end.
* Find quote under the cursor, cursor at end. // Returns true if found, else false.
* Returns TRUE if found, else FALSE. bool current_quote(
*/
int
current_quote(
oparg_T *oap, oparg_T *oap,
long count, long count,
int include, /* TRUE == include quote char */ bool include, // true == include quote char
int quotechar /* Quote character */ int quotechar // Quote character
) )
FUNC_ATTR_NONNULL_ALL
{ {
char_u *line = get_cursor_line_ptr(); char_u *line = get_cursor_line_ptr();
int col_end; int col_end;
int col_start = curwin->w_cursor.col; int col_start = curwin->w_cursor.col;
bool inclusive = false; bool inclusive = false;
int vis_empty = true; // Visual selection <= 1 char bool vis_empty = true; // Visual selection <= 1 char
int vis_bef_curs = false; // Visual starts before cursor bool vis_bef_curs = false; // Visual starts before cursor
int inside_quotes = false; // Looks like "i'" done before bool did_exclusive_adj = false; // adjusted pos for 'selection'
int selected_quote = false; // Has quote inside selection bool inside_quotes = false; // Looks like "i'" done before
bool selected_quote = false; // Has quote inside selection
int i; int i;
int restore_vis_bef = false; // resotre VIsual on abort bool restore_vis_bef = false; // resotre VIsual on abort
// Correct cursor when 'selection' is "exclusive". // When 'selection' is "exclusive" move the cursor to where it would be
// with 'selection' "inclusive", so that the logic is the same for both.
// The cursor then is moved forward after adjusting the area.
if (VIsual_active) { if (VIsual_active) {
// this only works within one line // this only works within one line
if (VIsual.lnum != curwin->w_cursor.lnum) { if (VIsual.lnum != curwin->w_cursor.lnum) {
@@ -3810,6 +3811,14 @@ current_quote(
vis_bef_curs = lt(VIsual, curwin->w_cursor); vis_bef_curs = lt(VIsual, curwin->w_cursor);
vis_empty = equalpos(VIsual, curwin->w_cursor); vis_empty = equalpos(VIsual, curwin->w_cursor);
if (*p_sel == 'e') { if (*p_sel == 'e') {
if (vis_bef_curs) {
dec_cursor();
did_exclusive_adj = true;
} else if (!vis_empty) {
dec(&VIsual);
did_exclusive_adj = true;
}
vis_empty = equalpos(VIsual, curwin->w_cursor);
if (!vis_bef_curs && !vis_empty) { if (!vis_bef_curs && !vis_empty) {
// VIsual needs to be start of Visual selection. // VIsual needs to be start of Visual selection.
pos_T t = curwin->w_cursor; pos_T t = curwin->w_cursor;
@@ -3819,8 +3828,6 @@ current_quote(
vis_bef_curs = true; vis_bef_curs = true;
restore_vis_bef = true; restore_vis_bef = true;
} }
dec_cursor();
vis_empty = equalpos(VIsual, curwin->w_cursor);
} }
} }
@@ -3846,7 +3853,7 @@ current_quote(
/* Find out if we have a quote in the selection. */ /* Find out if we have a quote in the selection. */
while (i <= col_end) while (i <= col_end)
if (line[i++] == quotechar) { if (line[i++] == quotechar) {
selected_quote = TRUE; selected_quote = true;
break; break;
} }
} }
@@ -3935,8 +3942,8 @@ current_quote(
} }
} }
/* When "include" is TRUE, include spaces after closing quote or before // When "include" is true, include spaces after closing quote or before
* the starting quote. */ // the starting quote.
if (include) { if (include) {
if (ascii_iswhite(line[col_end + 1])) if (ascii_iswhite(line[col_end + 1]))
while (ascii_iswhite(line[col_end + 1])) while (ascii_iswhite(line[col_end + 1]))
@@ -3982,9 +3989,10 @@ current_quote(
inclusive = true; inclusive = true;
if (VIsual_active) { if (VIsual_active) {
if (vis_empty || vis_bef_curs) { if (vis_empty || vis_bef_curs) {
/* decrement cursor when 'selection' is not exclusive */ // decrement cursor when 'selection' is not exclusive
if (*p_sel != 'e') if (*p_sel != 'e') {
dec_cursor(); dec_cursor();
}
} else { } else {
/* Cursor is at start of Visual area. Set the end of the Visual /* Cursor is at start of Visual area. Set the end of the Visual
* area when it was just inside quotes or it didn't end at a * area when it was just inside quotes or it didn't end at a
@@ -4008,11 +4016,13 @@ current_quote(
oap->inclusive = inclusive; oap->inclusive = inclusive;
} }
return OK; return true;
abort_search: abort_search:
if (VIsual_active && *p_sel == 'e') { if (VIsual_active && *p_sel == 'e') {
inc_cursor(); if (did_exclusive_adj) {
inc_cursor();
}
if (restore_vis_bef) { if (restore_vis_bef) {
pos_T t = curwin->w_cursor; pos_T t = curwin->w_cursor;

View File

@@ -1194,12 +1194,10 @@ static int find_tagfunc_tags(
taglist = rettv.vval.v_list; taglist = rettv.vval.v_list;
TV_LIST_ITER_CONST(taglist, li, { TV_LIST_ITER_CONST(taglist, li, {
char_u *mfp;
char_u *res_name; char_u *res_name;
char_u *res_fname; char_u *res_fname;
char_u *res_cmd; char_u *res_cmd;
char_u *res_kind; char_u *res_kind;
int len;
int has_extra = 0; int has_extra = 0;
int name_only = flags & TAG_NAMES; int name_only = flags & TAG_NAMES;
@@ -1208,7 +1206,7 @@ static int find_tagfunc_tags(
break; break;
} }
len = 2; size_t len = 2;
res_name = NULL; res_name = NULL;
res_fname = NULL; res_fname = NULL;
res_cmd = NULL; res_cmd = NULL;
@@ -1254,15 +1252,7 @@ static int find_tagfunc_tags(
break; break;
} }
if (name_only) { char_u *const mfp = name_only ? vim_strsave(res_name) : xmalloc(len + 2);
mfp = vim_strsave(res_name);
} else {
mfp = (char_u *)xmalloc((int)sizeof(char_u) + len + 1);
}
if (mfp == NULL) {
continue;
}
if (!name_only) { if (!name_only) {
char_u *p = mfp; char_u *p = mfp;
@@ -1669,12 +1659,9 @@ find_tags(
break; /* End the binary search without a match. */ break; /* End the binary search without a match. */
else else
search_info.curr_offset = offset; search_info.curr_offset = offset;
} } else if (state == TS_SKIP_BACK) {
/* // Skipping back (after a match during binary search).
* Skipping back (after a match during binary search). search_info.curr_offset -= lbuf_size * 2;
*/
else if (state == TS_SKIP_BACK) {
search_info.curr_offset -= LSIZE * 2;
if (search_info.curr_offset < 0) { if (search_info.curr_offset < 0) {
search_info.curr_offset = 0; search_info.curr_offset = 0;
rewind(fp); rewind(fp);
@@ -1690,7 +1677,7 @@ find_tags(
/* Adjust the search file offset to the correct position */ /* Adjust the search file offset to the correct position */
search_info.curr_offset_used = search_info.curr_offset; search_info.curr_offset_used = search_info.curr_offset;
vim_fseek(fp, search_info.curr_offset, SEEK_SET); vim_fseek(fp, search_info.curr_offset, SEEK_SET);
eof = vim_fgets(lbuf, LSIZE, fp); eof = vim_fgets(lbuf, lbuf_size, fp);
if (!eof && search_info.curr_offset != 0) { if (!eof && search_info.curr_offset != 0) {
/* The explicit cast is to work around a bug in gcc 3.4.2 /* The explicit cast is to work around a bug in gcc 3.4.2
* (repeated below). */ * (repeated below). */
@@ -1700,12 +1687,12 @@ find_tags(
vim_fseek(fp, search_info.low_offset, SEEK_SET); vim_fseek(fp, search_info.low_offset, SEEK_SET);
search_info.curr_offset = search_info.low_offset; search_info.curr_offset = search_info.low_offset;
} }
eof = vim_fgets(lbuf, LSIZE, fp); eof = vim_fgets(lbuf, lbuf_size, fp);
} }
/* skip empty and blank lines */ /* skip empty and blank lines */
while (!eof && vim_isblankline(lbuf)) { while (!eof && vim_isblankline(lbuf)) {
search_info.curr_offset = vim_ftell(fp); search_info.curr_offset = vim_ftell(fp);
eof = vim_fgets(lbuf, LSIZE, fp); eof = vim_fgets(lbuf, lbuf_size, fp);
} }
if (eof) { if (eof) {
/* Hit end of file. Skip backwards. */ /* Hit end of file. Skip backwards. */
@@ -1721,10 +1708,9 @@ find_tags(
else { else {
/* skip empty and blank lines */ /* skip empty and blank lines */
do { do {
if (use_cscope) eof = use_cscope
eof = cs_fgets(lbuf, LSIZE); ? cs_fgets(lbuf, lbuf_size)
else : vim_fgets(lbuf, lbuf_size, fp);
eof = vim_fgets(lbuf, LSIZE, fp);
} while (!eof && vim_isblankline(lbuf)); } while (!eof && vim_isblankline(lbuf));
if (eof) { if (eof) {
@@ -1849,19 +1835,14 @@ parse_line:
// When the line is too long the NUL will not be in the // When the line is too long the NUL will not be in the
// last-but-one byte (see vim_fgets()). // last-but-one byte (see vim_fgets()).
// Has been reported for Mozilla JS with extremely long names. // Has been reported for Mozilla JS with extremely long names.
// In that case we can't parse it and we ignore the line. // In that case we need to increase lbuf_size.
if (lbuf[LSIZE - 2] != NUL && !use_cscope) { if (lbuf[lbuf_size - 2] != NUL && !use_cscope) {
if (p_verbose >= 5) { lbuf_size *= 2;
verbose_enter(); xfree(lbuf);
MSG(_("Ignoring long line in tags file")); lbuf = xmalloc(lbuf_size);
verbose_leave(); // this will try the same thing again, make sure the offset is
} // different
if (state != TS_LINEAR) { search_info.curr_offset = 0;
// Avoid getting stuck.
linear = true;
state = TS_LINEAR;
vim_fseek(fp, search_info.low_offset, SEEK_SET);
}
continue; continue;
} }
@@ -2664,6 +2645,9 @@ static int jumpto_tag(
str = tagp.command; str = tagp.command;
for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; ) { for (pbuf_end = pbuf; *str && *str != '\n' && *str != '\r'; ) {
*pbuf_end++ = *str++; *pbuf_end++ = *str++;
if (pbuf_end - pbuf + 1 >= LSIZE) {
break;
}
} }
*pbuf_end = NUL; *pbuf_end = NUL;

View File

@@ -48,7 +48,8 @@ NEW_TESTS_IGNORE := $(NEW_TESTS_IN_ALOT) $(NEW_TESTS_ALOT) \
test_listlbr \ test_listlbr \
test_largefile \ test_largefile \
NEW_TESTS ?= $(addsuffix .res,$(sort $(filter-out $(NEW_TESTS_IGNORE),$(basename $(notdir $(wildcard test_*.vim))))) $(NEW_TESTS_ALOT)) NEW_TESTS ?= $(sort $(filter-out $(NEW_TESTS_IGNORE),$(basename $(notdir $(wildcard test_*.vim))))) $(NEW_TESTS_ALOT)
NEW_TESTS_RES ?= $(addsuffix .res,$(NEW_TESTS))
ifdef VALGRIND_GDB ifdef VALGRIND_GDB
@@ -112,6 +113,16 @@ fixff:
-$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \ -$(NVIM_PRG) $(NO_INITS) -u unix.vim "+argdo set ff=dos|upd" +q \
dotest.in dotest.in
# Execute an individual new style test, e.g.:
# make test_largefile
$(NEW_TESTS):
rm -f $@.res test.log messages
@MAKEFLAGS=--no-print-directory $(MAKE) -f Makefile $@.res
@cat messages
@if test -f test.log; then \
exit 1; \
fi
RM_ON_RUN := test.out X* viminfo RM_ON_RUN := test.out X* viminfo
RM_ON_START := test.ok RM_ON_START := test.ok
RUN_VIM := $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE -i viminfo --headless --noplugin -s dotest.in RUN_VIM := $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE -i viminfo --headless --noplugin -s dotest.in
@@ -172,7 +183,7 @@ newtests: newtestssilent
cat messages && cat test.log; \ cat messages && cat test.log; \
fi" fi"
newtestssilent: $(NEW_TESTS) newtestssilent: $(NEW_TESTS_RES)
%.res: %.vim .gdbinit %.res: %.vim .gdbinit
@echo "[OLDTEST] Running" $* @echo "[OLDTEST] Running" $*

View File

@@ -297,6 +297,8 @@ let s:flaky_tests = [
\ 'Test_repeat_three()', \ 'Test_repeat_three()',
\ 'Test_state()', \ 'Test_state()',
\ 'Test_stop_all_in_callback()', \ 'Test_stop_all_in_callback()',
\ 'Test_term_mouse_double_click_to_create_tab',
\ 'Test_term_mouse_multiple_clicks_to_visually_select()',
\ 'Test_terminal_composing_unicode()', \ 'Test_terminal_composing_unicode()',
\ 'Test_terminal_redir_file()', \ 'Test_terminal_redir_file()',
\ 'Test_terminal_tmap()', \ 'Test_terminal_tmap()',

View File

@@ -69,7 +69,8 @@ endfunc
" Read the port number from the Xportnr file. " Read the port number from the Xportnr file.
func GetPort() func GetPort()
let l = [] let l = []
for i in range(200) " with 200 it sometimes failed
for i in range(400)
try try
let l = readfile("Xportnr") let l = readfile("Xportnr")
catch catch
@@ -279,11 +280,15 @@ func GetVimCommand(...)
return cmd return cmd
endfunc endfunc
" Get the command to run Vim, with --clean. " Get the command to run Vim, with --clean instead of "-u NONE".
func GetVimCommandClean() func GetVimCommandClean()
let cmd = GetVimCommand() let cmd = GetVimCommand()
let cmd = substitute(cmd, '-u NONE', '--clean', '') let cmd = substitute(cmd, '-u NONE', '--clean', '')
let cmd = substitute(cmd, '--headless', '', '') let cmd = substitute(cmd, '--headless', '', '')
" Optionally run Vim under valgrind
" let cmd = 'valgrind --tool=memcheck --leak-check=yes --num-callers=25 --log-file=valgrind ' . cmd
return cmd return cmd
endfunc endfunc

View File

@@ -476,13 +476,19 @@ func Test_shortmess_F2()
call assert_match('file2', execute('bn', '')) call assert_match('file2', execute('bn', ''))
set shortmess+=F set shortmess+=F
call assert_true(empty(execute('bn', ''))) call assert_true(empty(execute('bn', '')))
" call assert_false(test_getvalue('need_fileinfo'))
call assert_true(empty(execute('bn', ''))) call assert_true(empty(execute('bn', '')))
" call assert_false(test_getvalue('need_fileinfo'))
set hidden set hidden
call assert_true(empty(execute('bn', ''))) call assert_true(empty(execute('bn', '')))
" call assert_false(test_getvalue('need_fileinfo'))
call assert_true(empty(execute('bn', ''))) call assert_true(empty(execute('bn', '')))
" call assert_false(test_getvalue('need_fileinfo'))
set nohidden set nohidden
call assert_true(empty(execute('bn', ''))) call assert_true(empty(execute('bn', '')))
" call assert_false(test_getvalue('need_fileinfo'))
call assert_true(empty(execute('bn', ''))) call assert_true(empty(execute('bn', '')))
" call assert_false(test_getvalue('need_fileinfo'))
" Accommodate Nvim default. " Accommodate Nvim default.
set shortmess-=F set shortmess-=F
call assert_match('file1', execute('bn', '')) call assert_match('file1', execute('bn', ''))

View File

@@ -241,7 +241,7 @@ func Test_sub_cmd_3()
call Run_SubCmd_Tests(tests) call Run_SubCmd_Tests(tests)
endfunc endfunc
" Test for submatch() on :substitue. " Test for submatch() on :substitute.
func Test_sub_cmd_4() func Test_sub_cmd_4()
set magic& set magic&
set cpo& set cpo&

View File

@@ -449,7 +449,8 @@ func Test_tag_line_toolong()
call assert_report(v:exception) call assert_report(v:exception)
catch /.*/ catch /.*/
endtry endtry
call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1]) call assert_equal('Searching tags file Xtags', split(execute('messages'), '\n')[-1])
call writefile([ call writefile([
\ '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML' \ '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML'
\ ], 'Xtags') \ ], 'Xtags')
@@ -460,8 +461,26 @@ func Test_tag_line_toolong()
call assert_report(v:exception) call assert_report(v:exception)
catch /.*/ catch /.*/
endtry endtry
call assert_equal('Ignoring long line in tags file', split(execute('messages'), '\n')[-1]) call assert_equal('Searching tags file Xtags', split(execute('messages'), '\n')[-1])
" binary search works in file with long line
call writefile([
\ 'asdfasfd nowhere 16',
\ 'foobar Xsomewhere 3; " 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567',
\ 'zasdfasfd nowhere 16',
\ ], 'Xtags')
call writefile([
\ 'one',
\ 'two',
\ 'trhee',
\ 'four',
\ ], 'Xsomewhere')
tag foobar
call assert_equal('Xsomewhere', expand('%'))
call assert_equal(3, getcurpos()[1])
call delete('Xtags') call delete('Xtags')
call delete('Xsomewhere')
set tags& set tags&
let &verbose = old_vbs let &verbose = old_vbs
endfunc endfunc

View File

@@ -46,11 +46,18 @@ func Test_quote_selection_selection_exclusive()
new new
call setline(1, "a 'bcde' f") call setline(1, "a 'bcde' f")
set selection=exclusive set selection=exclusive
exe "norm! fdvhi'y" exe "norm! fdvhi'y"
call assert_equal('bcde', @") call assert_equal('bcde', @")
let @"='dummy' let @"='dummy'
exe "norm! $gevi'y" exe "norm! $gevi'y"
call assert_equal('bcde', @") call assert_equal('bcde', @")
let @"='dummy'
exe "norm! 0fbhvi'y"
call assert_equal('bcde', @")
set selection&vim set selection&vim
bw! bw!
endfunc endfunc