diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ex_cmds.h | 8 | ||||
-rw-r--r-- | src/testdir/test_autocmd.vim | 3 | ||||
-rw-r--r-- | src/testdir/test_textformat.vim | 24 | ||||
-rw-r--r-- | src/testdir/test_vim9_class.vim | 52 | ||||
-rw-r--r-- | src/testdir/test_vim9_enum.vim | 11 | ||||
-rw-r--r-- | src/testdir/test_vim9_typealias.vim | 8 | ||||
-rw-r--r-- | src/textformat.c | 3 | ||||
-rw-r--r-- | src/version.c | 6 | ||||
-rw-r--r-- | src/vim9class.c | 7 |
9 files changed, 117 insertions, 5 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 70e5770..40dec4c 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -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_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT, + EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT, ADDR_NONE), EXCMD(CMD_all, "all", ex_all, EX_BANG|EX_RANGE|EX_COUNT|EX_TRLBAR, @@ -357,7 +357,7 @@ EXCMD(CMD_clast, "clast", ex_cc, EX_RANGE|EX_COUNT|EX_TRLBAR|EX_BANG, ADDR_UNSIGNED), EXCMD(CMD_class, "class", ex_class, - EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT, + EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT, ADDR_NONE), EXCMD(CMD_close, "close", ex_close, EX_BANG|EX_RANGE|EX_COUNT|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, @@ -597,7 +597,7 @@ EXCMD(CMD_enew, "enew", ex_edit, EX_BANG|EX_TRLBAR, ADDR_NONE), EXCMD(CMD_enum, "enum", ex_class, - EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT, + EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT, ADDR_NONE), EXCMD(CMD_eval, "eval", ex_eval, EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK, @@ -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_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_EXPORT, + EX_EXTRA|EX_CMDWIN|EX_LOCK_OK|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, diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 6745ecb..24e1daf 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -4687,6 +4687,9 @@ func Test_BufEnter_botline() edit Xxx2 au BufEnter Xxx1 call assert_true(line('w$') > 1) edit Xxx1 + + bwipe! Xxx1 + bwipe! Xxx2 au! BufEnter Xxx1 set hidden&vim endfunc diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim index a9cffd0..5d58486 100644 --- a/src/testdir/test_textformat.vim +++ b/src/testdir/test_textformat.vim @@ -1312,4 +1312,28 @@ func Test_textwdith_overflow() bw! endfunc +func Test_breakindent_reformat() + " Make sure textformatting uses the full width + " of the textwidth and does not consider the indent + " from breakindent into account when calculating the + " line length. Should break at tw 78 and not at 70 + CheckOption breakindent + new + 80vnew + 39vnew + setl ai breakindent tw=78 + let lorem = [ + \ ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam luctus', + \ ' lectus sodales, dictum augue vel, molestie augue. Duis sit amet', + \ ' rhoncus justo. Nullam posuere risus semper magna commodo scelerisque.', + \ ' Duis et venenatis sem. In rhoncus augue sed tempor mattis. Mauris id', + \ ' aliquet odio.'] + call setline(1, lorem) + norm! gqap + call assert_equal(lorem, getline(1, '$')) + bw! + bw! + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index 5957f57..bd06c6e 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -67,6 +67,42 @@ def Test_class_basic() END v9.CheckSourceFailure(lines, "E488: Trailing characters: | echo 'done'", 3) + # Additional command after "class name" + lines =<< trim END + vim9script + class Something | var x = 10 + endclass + END + v9.CheckSourceFailure(lines, "E488: Trailing characters: | var x = 10", 2) + + # Additional command after "object variable" + lines =<< trim END + vim9script + class Something + var l: list<number> = [] | var y = 10 + endclass + END + v9.CheckSourceFailure(lines, "E488: Trailing characters: | var y = 10", 3) + + # Additional command after "class variable" + lines =<< trim END + vim9script + class Something + static var d = {a: 10} | var y = 10 + endclass + END + v9.CheckSourceFailure(lines, "E488: Trailing characters: | var y = 10", 3) + + # Additional command after "object method" + lines =<< trim END + vim9script + class Something + def Foo() | var y = 10 + enddef + endclass + END + v9.CheckSourceFailure(lines, "E488: Trailing characters: | var y = 10", 3) + # Try to define a class with the same name as an existing variable lines =<< trim END vim9script @@ -2237,6 +2273,14 @@ def Test_interface_basics() END v9.CheckSourceFailure(lines, 'E1345: Not a valid command in an interface: return 5', 6) + # Additional commands after "interface name" + lines =<< trim END + vim9script + interface Something | var x = 10 | var y = 20 + endinterface + END + v9.CheckSourceFailure(lines, "E488: Trailing characters: | var x = 10", 2) + lines =<< trim END vim9script export interface EnterExit @@ -3233,6 +3277,14 @@ def Test_abstract_class() END v9.CheckSourceFailure(lines, 'E1316: Class can only be defined in Vim9 script', 1) + # Additional commands after "abstract class" + lines =<< trim END + vim9script + abstract class Something | var x = [] + endclass + END + v9.CheckSourceFailure(lines, "E488: Trailing characters: | var x = []", 2) + # Abstract class cannot have a "new" function lines =<< trim END vim9script diff --git a/src/testdir/test_vim9_enum.vim b/src/testdir/test_vim9_enum.vim index 274b556..bc54bee 100644 --- a/src/testdir/test_vim9_enum.vim +++ b/src/testdir/test_vim9_enum.vim @@ -97,7 +97,16 @@ def Test_enum_parse() vim9script enum Something | endenum END - v9.CheckSourceFailure(lines, 'E1420: Missing :endenum', 3) + v9.CheckSourceFailure(lines, 'E488: Trailing characters: | endenum', 2) + + # another command follows the enum name + lines =<< trim END + vim9script + enum Something | var x = 10 + Foo + endenum + END + v9.CheckSourceFailure(lines, 'E488: Trailing characters: | var x = 10', 2) # Try to define an enum with the same name as an existing variable lines =<< trim END diff --git a/src/testdir/test_vim9_typealias.vim b/src/testdir/test_vim9_typealias.vim index 998079c..cf540c2 100644 --- a/src/testdir/test_vim9_typealias.vim +++ b/src/testdir/test_vim9_typealias.vim @@ -172,6 +172,14 @@ def Test_typealias() END v9.CheckSourceSuccess(lines) + # another command follows a type alias + lines =<< trim END + vim9script + type MyType = number | var x = 20 + assert_equal(20, x) + END + v9.CheckSourceSuccess(lines) + # Sourcing a script twice (which will free script local variables) # Uses "lines" from the previous test new diff --git a/src/textformat.c b/src/textformat.c index 41ec2cf..d380899 100644 --- a/src/textformat.c +++ b/src/textformat.c @@ -59,9 +59,11 @@ internal_format( int safe_tw = trim_to_int(8 * (vimlong_T)textwidth); #ifdef FEAT_LINEBREAK int has_lbr = curwin->w_p_lbr; + int has_bri = curwin->w_p_bri; // make sure win_lbr_chartabsize() counts correctly curwin->w_p_lbr = FALSE; + curwin->w_p_bri = FALSE; #endif // When 'ai' is off we don't want a space under the cursor to be @@ -475,6 +477,7 @@ internal_format( #ifdef FEAT_LINEBREAK curwin->w_p_lbr = has_lbr; + curwin->w_p_bri = has_bri; #endif if (!format_only && haveto_redraw) { diff --git a/src/version.c b/src/version.c index 2bd0667..71e56a2 100644 --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,12 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 377, +/**/ + 376, +/**/ + 375, +/**/ 374, /**/ 373, diff --git a/src/vim9class.c b/src/vim9class.c index 52c2f76..4314b52 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -136,6 +136,13 @@ parse_member( fill_evalarg_from_eap(&evalarg, eap, FALSE); (void)skip_expr_concatenate(&init_arg, &expr_start, &expr_end, &evalarg); + init_arg = skipwhite(init_arg); + if (*init_arg != NUL) + { + semsg(_(e_trailing_characters_str), init_arg); + return FAIL; + } + // No type specified for the member. Set it to "any" and the correct // type will be set when the object is instantiated. if (type == NULL) |