Merge #9972 from janlazo/vim-8.1.1249

vim-patch:8.1.{613,1046,1249}
This commit is contained in:
Justin M. Keyes
2019-05-05 20:04:35 +02:00
committed by GitHub
6 changed files with 40 additions and 18 deletions

View File

@@ -5112,14 +5112,15 @@ chk_modeline(
*e = NUL; // truncate the set command *e = NUL; // truncate the set command
if (*s != NUL) { // skip over an empty "::" if (*s != NUL) { // skip over an empty "::"
const int secure_save = secure;
save_SID = current_SID; save_SID = current_SID;
current_SID = SID_MODELINE; current_SID = SID_MODELINE;
// Make sure no risky things are executed as a side effect. // Make sure no risky things are executed as a side effect.
secure++; secure = 1;
retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags); retval = do_set(s, OPT_MODELINE | OPT_LOCAL | flags);
secure--; secure = secure_save;
current_SID = save_SID; current_SID = save_SID;
if (retval == FAIL) { // stop if error found if (retval == FAIL) { // stop if error found
break; break;

View File

@@ -1833,34 +1833,30 @@ int do_set(
{ {
uint32_t *p = insecure_flag(opt_idx, opt_flags); uint32_t *p = insecure_flag(opt_idx, opt_flags);
int did_inc_secure = false; const int secure_saved = secure;
// When an option is set in the sandbox, from a // When an option is set in the sandbox, from a
// modeline or in secure mode, then deal with side // modeline or in secure mode, then deal with side
// effects in secure mode. Also when the value was // effects in secure mode. Also when the value was
// set with the P_INSECURE flag and is not // set with the P_INSECURE flag and is not
// completely replaced. // completely replaced.
if (secure if ((opt_flags & OPT_MODELINE)
|| sandbox != 0 || sandbox != 0
|| (opt_flags & OPT_MODELINE)
|| (!value_is_replaced && (*p & P_INSECURE))) { || (!value_is_replaced && (*p & P_INSECURE))) {
did_inc_secure = true; secure = 1;
secure++;
} }
// Handle side effects, and set the global value for // Handle side effects, and set the global value
// ":set" on local options. Note: when setting 'syntax' // for ":set" on local options. Note: when setting
// or 'filetype' autocommands may be triggered that can // 'syntax' or 'filetype' autocommands may be
// cause havoc. // triggered that can cause havoc.
errmsg = did_set_string_option(opt_idx, (char_u **)varp, errmsg = did_set_string_option(opt_idx, (char_u **)varp,
new_value_alloced, oldval, new_value_alloced, oldval,
errbuf, sizeof(errbuf), errbuf, sizeof(errbuf),
opt_flags, &value_checked); opt_flags, &value_checked);
if (did_inc_secure) { secure = secure_saved;
secure--; }
}
}
if (errmsg == NULL) { if (errmsg == NULL) {
if (!starting) { if (!starting) {

View File

@@ -4968,13 +4968,15 @@ static int nfa_did_time_out(void)
/// ///
/// When "nfa_endp" is not NULL it is a required end-of-match position. /// When "nfa_endp" is not NULL it is a required end-of-match position.
/// ///
/// Return TRUE if there is a match, FALSE otherwise. /// Return TRUE if there is a match, FALSE if there is no match,
/// NFA_TOO_EXPENSIVE if we end up with too many states.
/// When there is a match "submatch" contains the positions. /// When there is a match "submatch" contains the positions.
///
/// Note: Caller must ensure that: start != NULL. /// Note: Caller must ensure that: start != NULL.
static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start,
regsubs_T *submatch, regsubs_T *m) regsubs_T *submatch, regsubs_T *m)
{ {
int result; int result = false;
int flag = 0; int flag = 0;
bool go_to_nextline = false; bool go_to_nextline = false;
nfa_thread_T *t; nfa_thread_T *t;

View File

@@ -677,6 +677,29 @@ func Test_OptionSet_diffmode_close()
"delfunc! AutoCommandOptionSet "delfunc! AutoCommandOptionSet
endfunc endfunc
func Test_OptionSet_modeline()
throw 'skipped: Nvim does not support test_override()'
call test_override('starting', 1)
au! OptionSet
augroup set_tabstop
au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")})
augroup END
call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline')
set modeline
let v:errmsg = ''
call assert_fails('split XoptionsetModeline', 'E12:')
call assert_equal(7, &ts)
call assert_equal('', v:errmsg)
augroup set_tabstop
au!
augroup END
bwipe!
set ts&
call delete('XoptionsetModeline')
call test_override('starting', 0)
endfunc
" Test for Bufleave autocommand that deletes the buffer we are about to edit. " Test for Bufleave autocommand that deletes the buffer we are about to edit.
func Test_BufleaveWithDelete() func Test_BufleaveWithDelete()
new | edit Xfile1 new | edit Xfile1

View File

@@ -133,6 +133,7 @@ func Test_finddir()
let save_shellslash = &shellslash let save_shellslash = &shellslash
let save_dir = getcwd() let save_dir = getcwd()
set path=,, set path=,,
set shellslash
call CreateFiles() call CreateFiles()
cd Xdir1 cd Xdir1

View File

@@ -82,7 +82,6 @@ fun! Test_normal00_optrans()
endfunc endfunc
func! Test_normal01_keymodel() func! Test_normal01_keymodel()
throw "skipped: Nvim regression: 'keymodel'"
call Setup_NewWindow() call Setup_NewWindow()
" Test 1: depending on 'keymodel' <s-down> does something different " Test 1: depending on 'keymodel' <s-down> does something different
50 50