0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.1.0985: Vim9: some ex commands can be shortened

Problem:  Vim9: some ex commands can be shortened
Solution: disallow shortening of :abstract, :interface and :type
          (h-east)

closes: #16356

Signed-off-by: h-east <h.east.727@gmail.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
h-east
2025-01-03 10:19:45 +01:00
committed by Christian Brabandt
parent 663d18d610
commit aa979c763d
11 changed files with 101 additions and 20 deletions

View File

@@ -129,7 +129,7 @@ EXCMD(CMD_aboveleft, "aboveleft", ex_wrongmodifier,
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM,
ADDR_NONE),
EXCMD(CMD_abstract, "abstract", ex_class,
EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT,
EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE|EX_EXPORT,
ADDR_NONE),
EXCMD(CMD_all, "all", ex_all,
EX_BANG|EX_RANGE|EX_COUNT|EX_TRLBAR,
@@ -759,7 +759,7 @@ EXCMD(CMD_intro, "intro", ex_intro,
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_interface, "interface", ex_class,
EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT,
EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE|EX_EXPORT,
ADDR_NONE),
EXCMD(CMD_isearch, "isearch", ex_findpat,
EX_BANG|EX_RANGE|EX_DFLALL|EX_WHOLEFOLD|EX_EXTRA|EX_CMDWIN|EX_LOCK_OK,
@@ -1677,7 +1677,7 @@ EXCMD(CMD_tunmap, "tunmap", ex_unmap,
EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
ADDR_NONE),
EXCMD(CMD_type, "type", ex_type,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT,
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE|EX_EXPORT,
ADDR_NONE),
EXCMD(CMD_undo, "undo", ex_undo,
EX_RANGE|EX_COUNT|EX_ZEROR|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,

View File

@@ -2386,6 +2386,22 @@ def Test_interface_basics()
END
v9.CheckSourceFailure(lines, 'E1345: Not a valid command in an interface: return 5', 6)
# Test for "interface" cannot be abbreviated
lines =<< trim END
vim9script
inte Something
endinterface
END
v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: inte Something', 2)
# Test for "endinterface" cannot be abbreviated
lines =<< trim END
vim9script
interface Something
endin
END
v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: endin', 3)
# Additional commands after "interface name"
lines =<< trim END
vim9script
@@ -3525,6 +3541,14 @@ def Test_abstract_class()
END
v9.CheckSourceFailure(lines, 'E1316: Class can only be defined in Vim9 script', 1)
# Test for "abstract" cannot be abbreviated
lines =<< trim END
vim9script
abs class A
endclass
END
v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: abs class A', 2)
# Additional commands after "abstract class"
lines =<< trim END
vim9script

View File

@@ -48,6 +48,13 @@ def Test_typealias()
END
v9.CheckSourceFailure(lines, 'E1393: Type can only be defined in Vim9 script', 1)
# The complete "type" should be specified
lines =<< trim END
vim9script
typ Index = number
END
v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: typ Index = number', 2)
# Use :type without any arguments
lines =<< trim END
vim9script

View File

@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
985,
/**/
984,
/**/

View File

@@ -1738,6 +1738,7 @@ enum_set_internal_obj_vars(class_T *en, object_T *enval)
/*
* Handle ":class" and ":abstract class" up to ":endclass".
* Handle ":enum" up to ":endenum".
* Handle ":interface" up to ":endinterface".
*/
void