Mercurial > vim
comparison src/testdir/test_cmdline.vim @ 29964:444dd4cc49d6 v9.0.0320
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Commit: https://github.com/vim/vim/commit/54acb90d9e672315e3bd13f8dc71f828df97c868
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon Aug 29 16:21:25 2022 +0100
patch 9.0.0320: command line type of CmdlineChange differs from getcmdtype()
Problem: Command line type of CmdlineChange differs from getcmdtype().
Solution: Use the same type. (closes https://github.com/vim/vim/issues/11005)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 29 Aug 2022 17:30:03 +0200 |
parents | b366b19d1a3e |
children | d891115c0aea |
comparison
equal
deleted
inserted
replaced
29963:ee373646730e | 29964:444dd4cc49d6 |
---|---|
3262 set wildoptions& wildmenu& | 3262 set wildoptions& wildmenu& |
3263 endfunc | 3263 endfunc |
3264 | 3264 |
3265 func Test_setcmdline() | 3265 func Test_setcmdline() |
3266 func SetText(text, pos) | 3266 func SetText(text, pos) |
3267 autocmd CmdlineChanged * let g:cmdtype = expand('<afile>') | |
3267 call assert_equal(0, setcmdline(a:text)) | 3268 call assert_equal(0, setcmdline(a:text)) |
3268 call assert_equal(a:text, getcmdline()) | 3269 call assert_equal(a:text, getcmdline()) |
3269 call assert_equal(len(a:text) + 1, getcmdpos()) | 3270 call assert_equal(len(a:text) + 1, getcmdpos()) |
3271 call assert_equal(getcmdtype(), g:cmdtype) | |
3272 unlet g:cmdtype | |
3273 autocmd! CmdlineChanged | |
3270 | 3274 |
3271 call assert_equal(0, setcmdline(a:text, a:pos)) | 3275 call assert_equal(0, setcmdline(a:text, a:pos)) |
3272 call assert_equal(a:text, getcmdline()) | 3276 call assert_equal(a:text, getcmdline()) |
3273 call assert_equal(a:pos, getcmdpos()) | 3277 call assert_equal(a:pos, getcmdpos()) |
3274 | 3278 |
3279 return '' | 3283 return '' |
3280 endfunc | 3284 endfunc |
3281 | 3285 |
3282 call feedkeys(":\<C-R>=SetText('set rtp?', 2)\<CR>\<CR>", 'xt') | 3286 call feedkeys(":\<C-R>=SetText('set rtp?', 2)\<CR>\<CR>", 'xt') |
3283 call assert_equal('set rtp?', @:) | 3287 call assert_equal('set rtp?', @:) |
3288 | |
3289 call feedkeys(":let g:str = input('? ')\<CR>", 't') | |
3290 call feedkeys("\<C-R>=SetText('foo', 4)\<CR>\<CR>", 'xt') | |
3291 call assert_equal('foo', g:str) | |
3292 unlet g:str | |
3293 | |
3294 delfunc SetText | |
3284 | 3295 |
3285 " setcmdline() returns 1 when not editing the command line. | 3296 " setcmdline() returns 1 when not editing the command line. |
3286 call assert_equal(1, 'foo'->setcmdline()) | 3297 call assert_equal(1, 'foo'->setcmdline()) |
3287 | 3298 |
3288 " Called in custom function | 3299 " Called in custom function |
3292 endfunc | 3303 endfunc |
3293 | 3304 |
3294 com! -nargs=* -complete=custom,CustomComplete DoCmd : | 3305 com! -nargs=* -complete=custom,CustomComplete DoCmd : |
3295 call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') | 3306 call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') |
3296 call assert_equal('"DoCmd January February Mars', @:) | 3307 call assert_equal('"DoCmd January February Mars', @:) |
3308 delcom DoCmd | |
3309 delfunc CustomComplete | |
3297 | 3310 |
3298 " Called in <expr> | 3311 " Called in <expr> |
3299 cnoremap <expr>a setcmdline('let foo=') | 3312 cnoremap <expr>a setcmdline('let foo=') |
3300 call feedkeys(":a\<CR>", 'tx') | 3313 call feedkeys(":a\<CR>", 'tx') |
3301 call assert_equal('let foo=0', @:) | 3314 call assert_equal('let foo=0', @:) |