Merge #11467 from janlazo/vim-8.1.2345

vim-patch:8.1.{1252,1253,1254,1268,2345,2348,2349}
This commit is contained in:
Justin M. Keyes 2019-11-27 22:06:31 -08:00 committed by GitHub
commit 86c4a87fe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 5 deletions

View File

@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2019 Aug 26
" Last Change: 2019 Nov 26
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
@ -796,8 +796,8 @@ au BufNewFile,BufRead *.java,*.jav setf java
" JavaCC
au BufNewFile,BufRead *.jj,*.jjt setf javacc
" JavaScript, ECMAScript
au BufNewFile,BufRead *.js,*.javascript,*.es,*.mjs setf javascript
" JavaScript, ECMAScript, ES module script, CommonJS script
au BufNewFile,BufRead *.js,*.javascript,*.es,*.mjs,*.cjs setf javascript
" JavaScript with React
au BufNewFile,BufRead *.jsx setf javascriptreact

View File

@ -2872,7 +2872,7 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx)
int c;
char_u *p;
if (cmdidx == CMD_let) {
if (cmdidx == CMD_let || cmdidx == CMD_const) {
xp->xp_context = EXPAND_USER_VARS;
if (vim_strpbrk(arg, (char_u *)"\"'+-*/%.=!?~|&$([<>,#") == NULL) {
/* ":let var1 var2 ...": find last space. */

View File

@ -2126,6 +2126,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
case CMD_browse:
case CMD_call:
case CMD_confirm:
case CMD_const:
case CMD_delfunction:
case CMD_djump:
case CMD_dlist:
@ -2150,6 +2151,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
case CMD_leftabove:
case CMD_let:
case CMD_lockmarks:
case CMD_lockvar:
case CMD_lua:
case CMD_match:
case CMD_mzscheme:
@ -2178,6 +2180,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
case CMD_tilde:
case CMD_topleft:
case CMD_unlet:
case CMD_unlockvar:
case CMD_verbose:
case CMD_vertical:
case CMD_wincmd:
@ -3437,6 +3440,7 @@ const char * set_one_cmd_context(
case CMD_syntax:
set_context_in_syntax_cmd(xp, arg);
break;
case CMD_const:
case CMD_let:
case CMD_if:
case CMD_elseif:

View File

@ -78,26 +78,45 @@ func Test_map_completion()
call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <silent> <special>', getreg(':'))
map <Middle>x middle
map ,f commaf
map ,g commaf
map <Left> left
map <A-Left>x shiftleft
call feedkeys(":map ,\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map ,f', getreg(':'))
call feedkeys(":map ,\<Tab>\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map ,g', getreg(':'))
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <Left>', getreg(':'))
call feedkeys(":map <A-Left>\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal("\"map <A-Left>\<Tab>", getreg(':'))
unmap ,f
unmap ,g
unmap <Left>
unmap <A-Left>x
set cpo-=< cpo-=B cpo-=k
map <Left> left
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <Left>', getreg(':'))
call feedkeys(":map <M\<Tab>\<Home>\"\<CR>", 'xt')
" call assert_equal("\"map <M\<Tab>", getreg(':'))
unmap <Left>
" set cpo+=<
map <Left> left
exe "set t_k6=\<Esc>[17~"
call feedkeys(":map \<Esc>[17~x f6x\<CR>", 'xt')
call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"map <Left>', getreg(':'))
if !has('gui_running')
call feedkeys(":map \<Esc>[17~\<Tab>\<Home>\"\<CR>", 'xt')
" call assert_equal("\"map <F6>x", getreg(':'))
endif
unmap <Left>
call feedkeys(":unmap \<Esc>[17~x\<CR>", 'xt')
set cpo-=<
set cpo+=B
@ -113,6 +132,9 @@ func Test_map_completion()
call assert_equal('"map <Left>', getreg(':'))
unmap <Left>
" set cpo-=k
unmap <Middle>x
set cpo&vim
endfunc
func Test_match_completion()
@ -159,6 +181,7 @@ func Test_expr_completion()
endif
for cmd in [
\ 'let a = ',
\ 'const a = ',
\ 'if',
\ 'elseif',
\ 'while',

View File

@ -176,6 +176,26 @@ func Test_cannot_modify_existing_variable()
call assert_fails('const [i2, f2, s2] = [1, 1.1, "vim"]', 'E995:')
endfunc
func Test_const_with_condition()
const x = 0
if 0 | const x = 1 | endif
call assert_equal(0, x)
endfunc
func Test_lockvar()
let x = 'hello'
lockvar x
call assert_fails('let x = "there"', 'E741')
if 0 | unlockvar x | endif
call assert_fails('let x = "there"', 'E741')
unlockvar x
let x = 'there'
if 0 | lockvar x | endif
let x = 'again'
endfunc
func Test_const_with_index_access()
let l = [1, 2, 3]
call assert_fails('const l[0] = 4', 'E996:')

View File

@ -223,7 +223,7 @@ let s:filename_checks = {
\ 'jam': ['file.jpl', 'file.jpr'],
\ 'java': ['file.java', 'file.jav'],
\ 'javacc': ['file.jj', 'file.jjt'],
\ 'javascript': ['file.js', 'file.javascript', 'file.es', 'file.mjs'],
\ 'javascript': ['file.js', 'file.javascript', 'file.es', 'file.mjs', 'file.cjs'],
\ 'javascriptreact': ['file.jsx'],
\ 'jess': ['file.clp'],
\ 'jgraph': ['file.jgr'],

View File

@ -24,6 +24,10 @@ func Test_let()
let out = execute('let a {0 == 1 ? "a" : "b"}')
let s = "\na #1\nb #2"
call assert_equal(s, out)
let x = 0
if 0 | let x = 1 | endif
call assert_equal(0, x)
endfunc
func s:set_arg1(a) abort