0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 9.1.1607: :apple command detected as :append

Problem:  :apple command detected as :append (dai475694450)
Solution: Disallow to define a custom command with lower-case letter,
          correctly detect :insert/:change/:append ex commands
          (Hirohito Higashi).

fixes: #17893
closes: #17930

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito Higashi
2025-08-08 13:25:27 +02:00
committed by Christian Brabandt
parent eb2aebeb79
commit efd83d441b
3 changed files with 55 additions and 13 deletions

View File

@@ -6888,6 +6888,52 @@ func Test_script_lines()
catch
call assert_exception('Vim(function):E1145: Missing heredoc end marker: .')
endtry
" More test for :append, :change, :insert
let cmds = ["append", "change", "insert"]
let suffixes = ["", "!", "|", "|xyz", " "]
for c in cmds
" Single character (with some accepted trailing characters)
for s in suffixes
let cmd = c[:0] .. s
let line = ["func LinesCheck()", cmd, "", "endfunc", "call LinesCheck()"]
call writefile(line, 'Xfunc', 'D')
call assert_fails('source Xfunc', 'E1145: Missing heredoc end marker: .', $'"{cmd}"')
endfor
" Unnecessary arguments
let cmd = c[:2] .. " end"
let line[1] = cmd
call writefile(line, 'Xfunc', 'D')
call assert_fails('source Xfunc', 'E488: Trailing characters: end:', $'"{cmd}"')
" Extra characters at the end (i.e., other commands)
let cmd = c .. "x"
let line[1] = cmd
call writefile(line, 'Xfunc', 'D')
call assert_fails('source Xfunc', 'E492: Not an editor command:', $'"{cmd}"')
endfor
let line =<< trim END
func AppendCheck()
apple
endfunc
call AppendCheck()
END
call writefile(line, 'Xfunc', 'D')
call assert_fails('source Xfunc', 'E492: Not an editor command: apple')
let line =<< trim END
func AppendCheck()
command! apple :echo "hello apple"
apple
endfunc
call AppendCheck()
END
call writefile(line, 'Xfunc', 'D')
call assert_fails('source Xfunc', 'E183: User defined commands must start with an uppercase letter')
endfunc
"-------------------------------------------------------------------------------