mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #14238 from janlazo/vim-8.1.0958
vim-patch:8.1.{874,958,989,2380},8.2.{1621,2674}
This commit is contained in:
commit
3c497e214f
@ -1947,13 +1947,9 @@ void free_buf_options(buf_T *buf, int free_p_ff)
|
||||
clear_string_option(&buf->b_p_flp);
|
||||
clear_string_option(&buf->b_p_isk);
|
||||
clear_string_option(&buf->b_p_vsts);
|
||||
if (buf->b_p_vsts_nopaste) {
|
||||
xfree(buf->b_p_vsts_nopaste);
|
||||
}
|
||||
xfree(buf->b_p_vsts_nopaste);
|
||||
buf->b_p_vsts_nopaste = NULL;
|
||||
if (buf->b_p_vsts_array) {
|
||||
xfree(buf->b_p_vsts_array);
|
||||
}
|
||||
xfree(buf->b_p_vsts_array);
|
||||
buf->b_p_vsts_array = NULL;
|
||||
clear_string_option(&buf->b_p_vts);
|
||||
XFREE_CLEAR(buf->b_p_vts_array);
|
||||
|
@ -7269,7 +7269,6 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
char_u *p;
|
||||
char_u *line;
|
||||
int icase;
|
||||
int i;
|
||||
|
||||
if (keytyped == NUL) {
|
||||
// Can happen with CTRL-Y and CTRL-E on a short line.
|
||||
@ -7354,8 +7353,9 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
||||
&& p[curwin->w_cursor.col - 1] == ':'
|
||||
&& p[curwin->w_cursor.col - 2] == ':') {
|
||||
p[curwin->w_cursor.col - 1] = ' ';
|
||||
i = (cin_iscase(p, FALSE) || cin_isscopedecl(p)
|
||||
|| cin_islabel());
|
||||
const bool i = cin_iscase(p, false)
|
||||
|| cin_isscopedecl(p)
|
||||
|| cin_islabel();
|
||||
p = get_cursor_line_ptr();
|
||||
p[curwin->w_cursor.col - 1] = ':';
|
||||
if (i) {
|
||||
|
@ -5867,26 +5867,53 @@ int assert_inrange(typval_T *argvars)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
bool error = false;
|
||||
const varnumber_T lower = tv_get_number_chk(&argvars[0], &error);
|
||||
const varnumber_T upper = tv_get_number_chk(&argvars[1], &error);
|
||||
const varnumber_T actual = tv_get_number_chk(&argvars[2], &error);
|
||||
|
||||
if (error) {
|
||||
return 0;
|
||||
}
|
||||
if (actual < lower || actual > upper) {
|
||||
garray_T ga;
|
||||
prepare_assert_error(&ga);
|
||||
if (argvars[0].v_type == VAR_FLOAT
|
||||
|| argvars[1].v_type == VAR_FLOAT
|
||||
|| argvars[2].v_type == VAR_FLOAT) {
|
||||
const float_T flower = tv_get_float(&argvars[0]);
|
||||
const float_T fupper = tv_get_float(&argvars[1]);
|
||||
const float_T factual = tv_get_float(&argvars[2]);
|
||||
|
||||
char msg[55];
|
||||
vim_snprintf(msg, sizeof(msg),
|
||||
"range %" PRIdVARNUMBER " - %" PRIdVARNUMBER ",",
|
||||
lower, upper);
|
||||
fill_assert_error(&ga, &argvars[3], (char_u *)msg, NULL, &argvars[2],
|
||||
ASSERT_INRANGE);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
return 1;
|
||||
if (factual < flower || factual > fupper) {
|
||||
garray_T ga;
|
||||
prepare_assert_error(&ga);
|
||||
if (argvars[3].v_type != VAR_UNKNOWN) {
|
||||
char_u *const tofree = (char_u *)encode_tv2string(&argvars[3], NULL);
|
||||
ga_concat(&ga, tofree);
|
||||
xfree(tofree);
|
||||
} else {
|
||||
char msg[80];
|
||||
vim_snprintf(msg, sizeof(msg), "Expected range %g - %g, but got %g",
|
||||
flower, fupper, factual);
|
||||
ga_concat(&ga, (char_u *)msg);
|
||||
}
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
const varnumber_T lower = tv_get_number_chk(&argvars[0], &error);
|
||||
const varnumber_T upper = tv_get_number_chk(&argvars[1], &error);
|
||||
const varnumber_T actual = tv_get_number_chk(&argvars[2], &error);
|
||||
|
||||
if (error) {
|
||||
return 0;
|
||||
}
|
||||
if (actual < lower || actual > upper) {
|
||||
garray_T ga;
|
||||
prepare_assert_error(&ga);
|
||||
|
||||
char msg[55];
|
||||
vim_snprintf(msg, sizeof(msg),
|
||||
"range %" PRIdVARNUMBER " - %" PRIdVARNUMBER ",",
|
||||
lower, upper);
|
||||
fill_assert_error(&ga, &argvars[3], (char_u *)msg, NULL, &argvars[2],
|
||||
ASSERT_INRANGE);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -9002,7 +9002,7 @@ static void f_sign_jump(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
// Sign identifer
|
||||
// Sign identifier
|
||||
sign_id = (int)tv_get_number_chk(&argvars[0], ¬anum);
|
||||
if (notanum) {
|
||||
return;
|
||||
@ -9050,7 +9050,7 @@ static void f_sign_place(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
rettv->vval.v_number = -1;
|
||||
|
||||
// Sign identifer
|
||||
// Sign identifier
|
||||
sign_id = (int)tv_get_number_chk(&argvars[0], ¬anum);
|
||||
if (notanum) {
|
||||
return;
|
||||
|
@ -7494,7 +7494,7 @@ static void ex_syncbind(exarg_T *eap)
|
||||
|
||||
ctrl_o[0] = Ctrl_O;
|
||||
ctrl_o[1] = 0;
|
||||
ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE);
|
||||
ins_typebuf(ctrl_o, REMAP_NONE, 0, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -256,7 +256,7 @@ EXTERN linenr_T sourcing_lnum INIT(= 0); // line number of the source file
|
||||
|
||||
EXTERN int ex_nesting_level INIT(= 0); // nesting level
|
||||
EXTERN int debug_break_level INIT(= -1); // break below this level
|
||||
EXTERN int debug_did_msg INIT(= false); // did "debug mode" message
|
||||
EXTERN bool debug_did_msg INIT(= false); // did "debug mode" message
|
||||
EXTERN int debug_tick INIT(= 0); // breakpoint change count
|
||||
EXTERN int debug_backtrace_level INIT(= 0); // breakpoint backtrace level
|
||||
|
||||
|
@ -429,11 +429,9 @@ int get_number_indent(linenr_T lnum)
|
||||
return (int)col;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return appropriate space number for breakindent, taking influencing
|
||||
* parameters into account. Window must be specified, since it is not
|
||||
* necessarily always the current one.
|
||||
*/
|
||||
// Return appropriate space number for breakindent, taking influencing
|
||||
// parameters into account. Window must be specified, since it is not
|
||||
// necessarily always the current one.
|
||||
int get_breakindent_win(win_T *wp, const char_u *line)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1079,13 +1079,15 @@ do_execreg(
|
||||
}
|
||||
}
|
||||
escaped = vim_strsave_escape_csi(reg->y_array[i]);
|
||||
retval = ins_typebuf(escaped, remap, 0, TRUE, silent);
|
||||
retval = ins_typebuf(escaped, remap, 0, true, silent);
|
||||
xfree(escaped);
|
||||
if (retval == FAIL)
|
||||
if (retval == FAIL) {
|
||||
return FAIL;
|
||||
if (colon && ins_typebuf((char_u *)":", remap, 0, TRUE, silent)
|
||||
== FAIL)
|
||||
}
|
||||
if (colon
|
||||
&& ins_typebuf((char_u *)":", remap, 0, true, silent) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
reg_executing = regname == 0 ? '"' : regname; // disable the 'q' command
|
||||
}
|
||||
@ -1109,8 +1111,9 @@ static void put_reedit_in_typebuf(int silent)
|
||||
buf[0] = (char_u)(restart_edit == 'I' ? 'i' : restart_edit);
|
||||
buf[1] = NUL;
|
||||
}
|
||||
if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK)
|
||||
if (ins_typebuf(buf, REMAP_NONE, 0, true, silent) == OK) {
|
||||
restart_edit = NUL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1130,25 +1133,29 @@ static int put_in_typebuf(
|
||||
int retval = OK;
|
||||
|
||||
put_reedit_in_typebuf(silent);
|
||||
if (colon)
|
||||
retval = ins_typebuf((char_u *)"\n", REMAP_NONE, 0, TRUE, silent);
|
||||
if (colon) {
|
||||
retval = ins_typebuf((char_u *)"\n", REMAP_NONE, 0, true, silent);
|
||||
}
|
||||
if (retval == OK) {
|
||||
char_u *p;
|
||||
|
||||
if (esc)
|
||||
if (esc) {
|
||||
p = vim_strsave_escape_csi(s);
|
||||
else
|
||||
} else {
|
||||
p = s;
|
||||
if (p == NULL)
|
||||
}
|
||||
if (p == NULL) {
|
||||
retval = FAIL;
|
||||
else
|
||||
retval = ins_typebuf(p, esc ? REMAP_NONE : REMAP_YES,
|
||||
0, TRUE, silent);
|
||||
if (esc)
|
||||
} else {
|
||||
retval = ins_typebuf(p, esc ? REMAP_NONE : REMAP_YES, 0, true, silent);
|
||||
}
|
||||
if (esc) {
|
||||
xfree(p);
|
||||
}
|
||||
}
|
||||
if (colon && retval == OK) {
|
||||
retval = ins_typebuf((char_u *)":", REMAP_NONE, 0, true, silent);
|
||||
}
|
||||
if (colon && retval == OK)
|
||||
retval = ins_typebuf((char_u *)":", REMAP_NONE, 0, TRUE, silent);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -165,8 +165,8 @@ enum {
|
||||
SHM_WRI = 'w', ///< "[w]" instead of "written".
|
||||
SHM_ABBREVIATIONS = 'a', ///< Use abbreviations from #SHM_ALL_ABBREVIATIONS.
|
||||
SHM_WRITE = 'W', ///< Don't use "written" at all.
|
||||
SHM_TRUNC = 't', ///< Trunctate file messages.
|
||||
SHM_TRUNCALL = 'T', ///< Trunctate all messages.
|
||||
SHM_TRUNC = 't', ///< Truncate file messages.
|
||||
SHM_TRUNCALL = 'T', ///< Truncate all messages.
|
||||
SHM_OVER = 'o', ///< Overwrite file messages.
|
||||
SHM_OVERALL = 'O', ///< Overwrite more messages.
|
||||
SHM_SEARCH = 's', ///< No search hit bottom messages.
|
||||
|
@ -123,7 +123,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file,
|
||||
int shell_style = STYLE_ECHO;
|
||||
int check_spaces;
|
||||
static bool did_find_nul = false;
|
||||
bool ampersent = false;
|
||||
bool ampersand = false;
|
||||
// vimglob() function to define for Posix shell
|
||||
static char *sh_vimglob_func =
|
||||
"vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
|
||||
@ -245,7 +245,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file,
|
||||
p--;
|
||||
}
|
||||
if (*p == '&') { // remove trailing '&'
|
||||
ampersent = true;
|
||||
ampersand = true;
|
||||
*p = ' ';
|
||||
}
|
||||
STRCAT(command, ">");
|
||||
@ -309,7 +309,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file,
|
||||
shellopts |= kShellOptHideMess;
|
||||
}
|
||||
|
||||
if (ampersent) {
|
||||
if (ampersand) {
|
||||
STRCAT(command, "&"); // put the '&' after the redirection
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ int os_expand_wildcards(int num_pat, char_u **pat, int *num_file,
|
||||
|
||||
// When running in the background, give it some time to create the temp
|
||||
// file, but don't wait for it to finish.
|
||||
if (ampersent) {
|
||||
if (ampersand) {
|
||||
os_delay(10L, true);
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ void pum_redraw(void)
|
||||
char_u *p = NULL;
|
||||
int totwidth, width, w;
|
||||
int thumb_pos = 0;
|
||||
int thumb_heigth = 1;
|
||||
int thumb_height = 1;
|
||||
int round;
|
||||
int n;
|
||||
|
||||
@ -449,11 +449,11 @@ void pum_redraw(void)
|
||||
}
|
||||
|
||||
if (pum_scrollbar) {
|
||||
thumb_heigth = pum_height * pum_height / pum_size;
|
||||
if (thumb_heigth == 0) {
|
||||
thumb_heigth = 1;
|
||||
thumb_height = pum_height * pum_height / pum_size;
|
||||
if (thumb_height == 0) {
|
||||
thumb_height = 1;
|
||||
}
|
||||
thumb_pos = (pum_first * (pum_height - thumb_heigth)
|
||||
thumb_pos = (pum_first * (pum_height - thumb_height)
|
||||
+ (pum_size - pum_height) / 2)
|
||||
/ (pum_size - pum_height);
|
||||
}
|
||||
@ -616,11 +616,11 @@ void pum_redraw(void)
|
||||
if (pum_scrollbar > 0) {
|
||||
if (pum_rl) {
|
||||
grid_putchar(&pum_grid, ' ', row, col_off - pum_width,
|
||||
i >= thumb_pos && i < thumb_pos + thumb_heigth
|
||||
i >= thumb_pos && i < thumb_pos + thumb_height
|
||||
? attr_thumb : attr_scroll);
|
||||
} else {
|
||||
grid_putchar(&pum_grid, ' ', row, col_off + pum_width,
|
||||
i >= thumb_pos && i < thumb_pos + thumb_heigth
|
||||
i >= thumb_pos && i < thumb_pos + thumb_height
|
||||
? attr_thumb : attr_scroll);
|
||||
}
|
||||
}
|
||||
|
@ -5895,7 +5895,7 @@ static void regdump(char_u *pattern, bt_regprog_T *r)
|
||||
fprintf(f, " count %" PRId64, (int64_t)OPERAND_MIN(s));
|
||||
s += 4;
|
||||
} else if (op == RE_LNUM || op == RE_COL || op == RE_VCOL) {
|
||||
/* one int plus comperator */
|
||||
// one int plus comparator
|
||||
fprintf(f, " count %" PRId64, (int64_t)OPERAND_MIN(s));
|
||||
s += 5;
|
||||
}
|
||||
@ -7139,6 +7139,7 @@ list_T *reg_submatch_list(int no)
|
||||
tv_list_append_string(list, s, (const char *)rsm.sm_match->endp[no] - s);
|
||||
}
|
||||
|
||||
tv_list_ref(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -559,7 +559,9 @@ static char_u *nfa_get_match_text(nfa_state_T *start)
|
||||
*/
|
||||
static void realloc_post_list(void)
|
||||
{
|
||||
size_t new_max = (post_end - post_start) + 1000;
|
||||
// For weird patterns the number of states can be very high. Increasing by
|
||||
// 50% seems a reasonable compromise between memory use and speed.
|
||||
const size_t new_max = (post_end - post_start) * 3 / 2;
|
||||
int *new_start = xrealloc(post_start, new_max * sizeof(int));
|
||||
post_ptr = new_start + (post_ptr - post_start);
|
||||
post_end = new_start + new_max;
|
||||
|
@ -31,14 +31,11 @@ endif
|
||||
SCRIPTS ?= $(SCRIPTS_DEFAULT)
|
||||
|
||||
# Tests using runtest.vim.
|
||||
NEW_TESTS_ALOT := test_alot_utf8 test_alot
|
||||
NEW_TESTS_ALOT := test_alot_utf8 test_alot test_alot_latin
|
||||
NEW_TESTS_IN_ALOT := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' $(addsuffix .vim,$(NEW_TESTS_ALOT)))
|
||||
NEW_TESTS_IN_ALOT_LATIN := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' test_alot_latin.vim)
|
||||
# Ignored tests.
|
||||
# test_alot_latin: Nvim does not allow setting encoding.
|
||||
# test_largefile: uses too much resources to run on CI.
|
||||
NEW_TESTS_IGNORE := \
|
||||
test_alot_latin $(NEW_TESTS_IN_ALOT_LATIN) \
|
||||
test_largefile \
|
||||
|
||||
NEW_TESTS := $(sort $(basename $(notdir $(wildcard test_*.vim))))
|
||||
|
@ -4,7 +4,4 @@
|
||||
" These tests use latin1 'encoding'. Setting 'encoding' is in the individual
|
||||
" files, so that they can be run by themselves.
|
||||
|
||||
" Nvim does not allow setting 'encoding', so skip this test group.
|
||||
finish
|
||||
|
||||
source test_regexp_latin.vim
|
||||
|
@ -52,6 +52,37 @@ func Test_assert_fails_in_try_block()
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_assert_inrange()
|
||||
call assert_equal(0, assert_inrange(7, 7, 7))
|
||||
call assert_equal(0, assert_inrange(5, 7, 5))
|
||||
call assert_equal(0, assert_inrange(5, 7, 6))
|
||||
call assert_equal(0, assert_inrange(5, 7, 7))
|
||||
call assert_equal(1, assert_inrange(5, 7, 4))
|
||||
call assert_match("Expected range 5 - 7, but got 4", v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
call assert_equal(1, assert_inrange(5, 7, 8))
|
||||
call assert_match("Expected range 5 - 7, but got 8", v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
|
||||
call assert_fails('call assert_inrange(1, 1)', 'E119:')
|
||||
|
||||
if has('float')
|
||||
call assert_equal(0, assert_inrange(7.0, 7, 7))
|
||||
call assert_equal(0, assert_inrange(7, 7.0, 7))
|
||||
call assert_equal(0, assert_inrange(7, 7, 7.0))
|
||||
call assert_equal(0, assert_inrange(5, 7, 5.0))
|
||||
call assert_equal(0, assert_inrange(5, 7, 6.0))
|
||||
call assert_equal(0, assert_inrange(5, 7, 7.0))
|
||||
|
||||
call assert_equal(1, assert_inrange(5, 7, 4.0))
|
||||
call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
call assert_equal(1, assert_inrange(5, 7, 8.0))
|
||||
call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Must be last.
|
||||
func Test_zz_quit_detected()
|
||||
" Verify that if a test function ends Vim the test script detects this.
|
||||
|
@ -1,5 +1,5 @@
|
||||
" Tests for regexp in latin1 encoding
|
||||
set encoding=latin1
|
||||
" set encoding=latin1
|
||||
scriptencoding latin1
|
||||
|
||||
func s:equivalence_test()
|
||||
@ -22,11 +22,13 @@ func s:equivalence_test()
|
||||
endfunc
|
||||
|
||||
func Test_equivalence_re1()
|
||||
throw 'skipped: Nvim does not support enc=latin1'
|
||||
set re=1
|
||||
call s:equivalence_test()
|
||||
endfunc
|
||||
|
||||
func Test_equivalence_re2()
|
||||
throw 'skipped: Nvim does not support enc=latin1'
|
||||
set re=2
|
||||
call s:equivalence_test()
|
||||
endfunc
|
||||
@ -39,6 +41,17 @@ func Test_range_with_newline()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_pattern_compile_speed()
|
||||
if !exists('+spellcapcheck') || !has('reltime')
|
||||
return
|
||||
endif
|
||||
let start = reltime()
|
||||
" this used to be very slow, not it should be about a second
|
||||
set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179}
|
||||
call assert_inrange(0.01, 10.0, reltimefloat(reltime(start)))
|
||||
set spc=
|
||||
endfunc
|
||||
|
||||
func Test_get_equi_class()
|
||||
new
|
||||
" Incomplete equivalence class caused invalid memory access
|
||||
@ -87,6 +100,7 @@ func Test_multi_failure()
|
||||
endfunc
|
||||
|
||||
func Test_recursive_addstate()
|
||||
throw 'skipped: TODO: '
|
||||
" This will call addstate() recursively until it runs into the limit.
|
||||
let lnum = search('\v((){328}){389}')
|
||||
call assert_equal(0, lnum)
|
||||
|
@ -746,3 +746,12 @@ func Test_sub_beyond_end()
|
||||
call assert_equal('#', getline(1))
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_submatch_list_concatenate()
|
||||
let pat = 'A\(.\)'
|
||||
let Rep = {-> string([submatch(0, 1)] + [[submatch(1)]])}
|
||||
" call substitute('A1', pat, Rep, '')->assert_equal("[['A1'], ['1']]")
|
||||
call assert_equal(substitute('A1', pat, Rep, ''), "[['A1'], ['1']]")
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user