Skip to content

Commit 67fbdfe

Browse files
committed
patch 8.2.1045: Vim9: line break before operator does not work
Problem: Vim9: line break before operator does not work. Solution: Peek the next line for an operator.
1 parent ef6d86c commit 67fbdfe

3 files changed

Lines changed: 121 additions & 28 deletions

File tree

src/testdir/test_vim9_expr.vim

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ def Test_expr1()
1313
assert_equal('one', 0.1 ? 'one' : 'two')
1414
endif
1515
assert_equal('one', 'x' ? 'one' : 'two')
16+
assert_equal('one', 'x'
17+
? 'one'
18+
: 'two')
1619
assert_equal('one', 0z1234 ? 'one' : 'two')
1720
assert_equal('one', [0] ? 'one' : 'two')
1821
assert_equal('one', #{x: 0} ? 'one' : 'two')
@@ -70,6 +73,8 @@ def Test_expr2()
7073
0 ||
7174
7)
7275
assert_equal(0, 0 || 0)
76+
assert_equal(0, 0
77+
|| 0)
7378
assert_equal('', 0 || '')
7479

7580
g:vals = []
@@ -81,7 +86,9 @@ def Test_expr2()
8186
assert_equal([0, 5], g:vals)
8287

8388
g:vals = []
84-
assert_equal(4, Record(0) || Record(4) || Record(0))
89+
assert_equal(4, Record(0)
90+
|| Record(4)
91+
|| Record(0))
8592
assert_equal([0, 4], g:vals)
8693

8794
g:vals = []
@@ -104,7 +111,9 @@ def Test_expr3()
104111
assert_equal(0, 0 &&
105112
0 &&
106113
7)
107-
assert_equal(7, 2 && 3 && 7)
114+
assert_equal(7, 2
115+
&& 3
116+
&& 7)
108117
assert_equal(0, 0 && 0)
109118
assert_equal(0, 0 && '')
110119
assert_equal('', 8 && '')
@@ -158,7 +167,8 @@ def Test_expr4_equal()
158167
assert_equal(true, true == true)
159168
assert_equal(false, true ==
160169
false)
161-
assert_equal(true, true == trueVar)
170+
assert_equal(true, true
171+
== trueVar)
162172
assert_equal(false, true == falseVar)
163173
assert_equal(true, true == g:atrue)
164174
assert_equal(false, g:atrue == false)
@@ -250,7 +260,8 @@ def Test_expr4_notequal()
250260
assert_equal(false, true != true)
251261
assert_equal(true, true !=
252262
false)
253-
assert_equal(false, true != trueVar)
263+
assert_equal(false, true
264+
!= trueVar)
254265
assert_equal(true, true != falseVar)
255266
assert_equal(false, true != g:atrue)
256267
assert_equal(true, g:atrue != false)
@@ -334,7 +345,8 @@ def Test_expr4_greater()
334345
assert_true(nr2 >
335346
1)
336347
assert_false(nr2 > 2)
337-
assert_false(nr2 > 3)
348+
assert_false(nr2
349+
> 3)
338350
if has('float')
339351
let ff = 2.0
340352
assert_true(ff > 0.0)
@@ -367,7 +379,8 @@ def Test_expr4_smaller()
367379
assert_false(2 < 0)
368380
assert_false(2 <
369381
2)
370-
assert_true(2 < 3)
382+
assert_true(2
383+
< 3)
371384
let nr2 = 2
372385
assert_false(nr2 < 0)
373386
assert_false(nr2 < 2)
@@ -385,7 +398,8 @@ def Test_expr4_smallerequal()
385398
assert_false(2 <= 0)
386399
assert_false(2 <=
387400
1)
388-
assert_true(2 <= 2)
401+
assert_true(2
402+
<= 2)
389403
assert_true(2 <= 3)
390404
let nr2 = 2
391405
assert_false(nr2 <= 0)
@@ -404,13 +418,17 @@ enddef
404418
" test =~ comperator
405419
def Test_expr4_match()
406420
assert_equal(false, '2' =~ '0')
421+
assert_equal(false, ''
422+
=~ '0')
407423
assert_equal(true, '2' =~
408424
'[0-9]')
409425
enddef
410426

411427
" test !~ comperator
412428
def Test_expr4_nomatch()
413429
assert_equal(true, '2' !~ '0')
430+
assert_equal(true, ''
431+
!~ '0')
414432
assert_equal(false, '2' !~
415433
'[0-9]')
416434
enddef
@@ -424,7 +442,8 @@ def Test_expr4_is()
424442
other)
425443

426444
let myblob = 0z1234
427-
assert_false(myblob is 0z1234)
445+
assert_false(myblob
446+
is 0z1234)
428447
let otherblob = myblob
429448
assert_true(myblob is otherblob)
430449
enddef
@@ -439,7 +458,8 @@ def Test_expr4_isnot()
439458
other)
440459

441460
let myblob = 0z1234
442-
assert_true(myblob isnot 0z1234)
461+
assert_true(myblob
462+
isnot 0z1234)
443463
let otherblob = myblob
444464
assert_false(myblob isnot otherblob)
445465
enddef
@@ -522,26 +542,30 @@ def Test_expr5()
522542
assert_equal(66, 60 + 6)
523543
assert_equal(70, 60 +
524544
g:anint)
525-
assert_equal(9, g:alsoint + 5)
545+
assert_equal(9, g:alsoint
546+
+ 5)
526547
assert_equal(14, g:alsoint + g:anint)
527548
assert_equal([1, 2, 3, 4], [1] + g:alist)
528549

529550
assert_equal(54, 60 - 6)
530551
assert_equal(50, 60 -
531552
g:anint)
532-
assert_equal(-1, g:alsoint - 5)
553+
assert_equal(-1, g:alsoint
554+
- 5)
533555
assert_equal(-6, g:alsoint - g:anint)
534556

535557
assert_equal('hello', 'hel' .. 'lo')
536558
assert_equal('hello 123', 'hello ' ..
537559
123)
538-
assert_equal('hello 123', 'hello ' .. 123)
560+
assert_equal('hello 123', 'hello '
561+
.. 123)
539562
assert_equal('123 hello', 123 .. ' hello')
540563
assert_equal('123456', 123 .. 456)
541564

542565
assert_equal([1, 2, 3, 4], [1, 2] + [3, 4])
543566
assert_equal(0z11223344, 0z1122 + 0z3344)
544-
assert_equal(0z112201ab, 0z1122 + g:ablob)
567+
assert_equal(0z112201ab, 0z1122
568+
+ g:ablob)
545569
assert_equal(0z01ab3344, g:ablob + 0z3344)
546570
assert_equal(0z01ab01ab, g:ablob + g:ablob)
547571
enddef
@@ -554,13 +578,15 @@ def Test_expr5_float()
554578
assert_equal(66.0, 60.0 + 6)
555579
assert_equal(66.0, 60 +
556580
6.0)
557-
assert_equal(5.1, g:afloat + 5)
581+
assert_equal(5.1, g:afloat
582+
+ 5)
558583
assert_equal(8.1, 8 + g:afloat)
559584
assert_equal(10.1, g:anint + g:afloat)
560585
assert_equal(10.1, g:afloat + g:anint)
561586

562587
assert_equal(54.0, 60.0 - 6.0)
563-
assert_equal(54.0, 60.0 - 6)
588+
assert_equal(54.0, 60.0
589+
- 6)
564590
assert_equal(54.0, 60 - 6.0)
565591
assert_equal(-4.9, g:afloat - 5)
566592
assert_equal(7.9, 8 - g:afloat)
@@ -599,20 +625,23 @@ def Test_expr6()
599625
assert_equal(36, 6 * 6)
600626
assert_equal(24, 6 *
601627
g:alsoint)
602-
assert_equal(24, g:alsoint * 6)
628+
assert_equal(24, g:alsoint
629+
* 6)
603630
assert_equal(40, g:anint * g:alsoint)
604631

605632
assert_equal(10, 60 / 6)
606633
assert_equal(6, 60 /
607634
g:anint)
608635
assert_equal(1, g:anint / 6)
609-
assert_equal(2, g:anint / g:alsoint)
636+
assert_equal(2, g:anint
637+
/ g:alsoint)
610638

611639
assert_equal(5, 11 % 6)
612640
assert_equal(4, g:anint % 6)
613641
assert_equal(3, 13 %
614642
g:anint)
615-
assert_equal(2, g:anint % g:alsoint)
643+
assert_equal(2, g:anint
644+
% g:alsoint)
616645

617646
assert_equal(4, 6 * 4 / 6)
618647

@@ -623,8 +652,10 @@ def Test_expr6()
623652
if has('float')
624653
let xf = [2.0]
625654
let yf = [3.0]
626-
assert_equal(5.0, xf[0] + yf[0])
627-
assert_equal(6.0, xf[0] * yf[0])
655+
assert_equal(5.0, xf[0]
656+
+ yf[0])
657+
assert_equal(6.0, xf[0]
658+
* yf[0])
628659
endif
629660

630661
call CheckDefFailure(["let x = 6 * xxx"], 'E1001')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1045,
757759
/**/
758760
1044,
759761
/**/

0 commit comments

Comments
 (0)