mirror of
https://github.com/neovim/neovim.git
synced 2026-07-17 22:51:20 +00:00
vim-patch:partial:9.2.0573: Vim9: missing EX_WHOLE on some block keywords (#40071)
Problem: Several Vim9 keywords lack EX_WHOLE and can be shortened in
Vim9 script, inconsistent with endif/enddef/endfor/endwhile/
endtry which already have it. The error from :endd in a
nested function also hardcodes "enddef" instead of reporting
what the user typed. fullcommand("ho") returns "horizontal"
even though :ho is below the documented 3-char minimum.
Solution: Add EX_WHOLE to :class, :def, :endclass, :endinterface,
:endenum, :public and :static. In get_function_body() pass
the user-typed command to the error message. Force :ho to
CMD_SIZE in find_ex_command() so fullcommand() reflects the
modifier minimum. Extend tests and documentation accordingly
(Peter Kenny).
fixes: vim/vim#20032
closes: vim/vim#20191
38d9a16eba
Co-authored-by: Peter Kenny <github.com@k1w1.cyou>
This commit is contained in:
@@ -7620,6 +7620,33 @@ func Test_catch_pattern_trailing_chars()
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" Test using fullcommand() {{{1
|
||||
func Test_builtin_fullcommand()
|
||||
" :hor is the minimum abbreviation of :horizontal; :ho is invalid
|
||||
call assert_equal('', fullcommand('ho'))
|
||||
call assert_equal('horizontal', fullcommand('hor'))
|
||||
|
||||
" :k takes one {a-zA-Z'} mark argument and optional whitespace
|
||||
call assert_equal('k', fullcommand('k'))
|
||||
call assert_equal('k', fullcommand(':k'))
|
||||
call assert_equal('k', fullcommand('karrrrrgh!'))
|
||||
|
||||
" :dl is "delete and list" in a legacy Vim script scope
|
||||
call assert_equal('delete', fullcommand('dl'))
|
||||
|
||||
" :s two and three letter commands
|
||||
call assert_equal('substitute', fullcommand('sIr'))
|
||||
call assert_equal('substitute', fullcommand('sIrarrrrrgh!'))
|
||||
|
||||
" :finally
|
||||
call assert_equal('finally', fullcommand('fina'))
|
||||
" 'final' - returns 'final', a Vim9 script-exclusive keyword
|
||||
" - is a valid shortening of :finally in legacy Vim script
|
||||
"call assert_equal('final', fullcommand('final'))
|
||||
call assert_equal('finally', fullcommand('finall'))
|
||||
|
||||
endfunc
|
||||
|
||||
"-------------------------------------------------------------------------------
|
||||
" Modelines {{{1
|
||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||
|
||||
Reference in New Issue
Block a user