robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each , after_each , setup , teardown , finally = 6t . describe , t . it , t . before_each , t . after_each , t . setup , t . teardown , t . finally 7local feed =n . feed 8local clear =n . clear 9local command =n . command 10local insert =n . insert 11local write_file =t . write_file 12local dedent =t . dedent 13local exec =n . exec 14local eq =t . eq 15local api =n . api 16 17local function WriteDiffFiles ( text1 , text2 ) 18write_file ( 'Xdifile1' , text1 ) 19write_file ( 'Xdifile2' , text2 ) 20command ( 'checktime' ) 21end 22 23local function WriteDiffFiles3 ( text1 , text2 , text3 ) 24write_file ( 'Xdifile1' , text1 ) 25write_file ( 'Xdifile2' , text2 ) 26write_file ( 'Xdifile3' , text3 ) 27command ( 'checktime' ) 28end 29 30before_each ( clear ) 31 32describe ( 'Diff mode screen' , function () 33local fname ='Xtest-functional-diff-screen-1' 34local fname_2 =fname .. '.2' 35local screen 36 37local reread =function () 38feed ( ':e<cr><c-w>w:e<cr><c-w>w' ) 39end 40 41setup ( function () 42os . remove ( fname ) 43os . remove ( fname_2 ) 44end ) 45 46teardown ( function () 47os . remove ( fname ) 48os . remove ( fname_2 ) 49end ) 50 51before_each ( function () 52feed ( ':e ' .. fname_2 .. '<cr>' ) 53feed ( ':vnew ' .. fname .. '<cr>' ) 54feed ( ':diffthis<cr>' ) 55feed ( '<c-w>w:diffthis<cr><c-w>w' ) 56 57screen =Screen . new ( 40 , 16 ) 58end ) 59 60it ( 'Add a line in beginning of file 2' , function () 61write_file ( fname , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 62write_file ( fname_2 , '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 63reread () 64 65feed ( ':set diffopt=filler<cr>' ) 66screen : expect ( [[ 67{7: }{23:------------------}│{7: }{22:0 }| 68{7: }^1 │{7: }1 | 69{7: }2 │{7: }2 | 70{7: }3 │{7: }3 | 71{7: }4 │{7: }4 | 72{7: }5 │{7: }5 | 73{7: }6 │{7: }6 | 74{7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}| 75{1:~ }│{1:~ }|*6 76{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 77:set diffopt=filler | 78]] ) 79 80feed ( ':set diffopt+=internal<cr>' ) 81screen : expect ( [[ 82{7: }{23:------------------}│{7: }{22:0 }| 83{7: }^1 │{7: }1 | 84{7: }2 │{7: }2 | 85{7: }3 │{7: }3 | 86{7: }4 │{7: }4 | 87{7: }5 │{7: }5 | 88{7: }6 │{7: }6 | 89{7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}| 90{1:~ }│{1:~ }|*6 91{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 92:set diffopt+=internal | 93]] ) 94end ) 95 96it ( 'Add a line in beginning of file 1' , function () 97write_file ( fname , '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 98write_file ( fname_2 , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 99reread () 100 101feed ( ':set diffopt=filler<cr>' ) 102screen : expect ( [[ 103{7: }{22:^0 }│{7: }{23:-----------------}| 104{7: }1 │{7: }1 | 105{7: }2 │{7: }2 | 106{7: }3 │{7: }3 | 107{7: }4 │{7: }4 | 108{7: }5 │{7: }5 | 109{7: }6 │{7: }6 | 110{7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}| 111{1:~ }│{1:~ }|*6 112{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 113:set diffopt=filler | 114]] ) 115 116feed ( ':set diffopt+=internal<cr>' ) 117screen : expect ( [[ 118{7: }{22:^0 }│{7: }{23:-----------------}| 119{7: }1 │{7: }1 | 120{7: }2 │{7: }2 | 121{7: }3 │{7: }3 | 122{7: }4 │{7: }4 | 123{7: }5 │{7: }5 | 124{7: }6 │{7: }6 | 125{7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}| 126{1:~ }│{1:~ }|*6 127{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 128:set diffopt+=internal | 129]] ) 130end ) 131 132it ( 'Add a line at the end of file 2' , function () 133write_file ( fname , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 134write_file ( fname_2 , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n' , false ) 135reread () 136 137feed ( ':set diffopt=filler<cr>' ) 138screen : expect ( [[ 139{7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}| 140{7: }5 │{7: }5 | 141{7: }6 │{7: }6 | 142{7: }7 │{7: }7 | 143{7: }8 │{7: }8 | 144{7: }9 │{7: }9 | 145{7: }10 │{7: }10 | 146{7: }{23:------------------}│{7: }{22:11 }| 147{1:~ }│{1:~ }|*6 148{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 149:set diffopt=filler | 150]] ) 151 152feed ( ':set diffopt+=internal<cr>' ) 153screen : expect ( [[ 154{7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}| 155{7: }5 │{7: }5 | 156{7: }6 │{7: }6 | 157{7: }7 │{7: }7 | 158{7: }8 │{7: }8 | 159{7: }9 │{7: }9 | 160{7: }10 │{7: }10 | 161{7: }{23:------------------}│{7: }{22:11 }| 162{1:~ }│{1:~ }|*6 163{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 164:set diffopt+=internal | 165]] ) 166 167screen : try_resize ( 40 , 9 ) 168screen : expect ( [[ 169{7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}| 170{7: }5 │{7: }5 | 171{7: }6 │{7: }6 | 172{7: }7 │{7: }7 | 173{7: }8 │{7: }8 | 174{7: }9 │{7: }9 | 175{7: }10 │{7: }10 | 176{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 177| 178]] ) 179end ) 180 181it ( 'Add a line at the end of file 1' , function () 182write_file ( fname , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n' , false ) 183write_file ( fname_2 , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 184reread () 185 186feed ( ':set diffopt=filler<cr>' ) 187screen : expect ( [[ 188{7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}| 189{7: }5 │{7: }5 | 190{7: }6 │{7: }6 | 191{7: }7 │{7: }7 | 192{7: }8 │{7: }8 | 193{7: }9 │{7: }9 | 194{7: }10 │{7: }10 | 195{7: }{22:11 }│{7: }{23:-----------------}| 196{1:~ }│{1:~ }|*6 197{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 198:set diffopt=filler | 199]] ) 200 201feed ( ':set diffopt+=internal<cr>' ) 202screen : expect ( [[ 203{7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}| 204{7: }5 │{7: }5 | 205{7: }6 │{7: }6 | 206{7: }7 │{7: }7 | 207{7: }8 │{7: }8 | 208{7: }9 │{7: }9 | 209{7: }10 │{7: }10 | 210{7: }{22:11 }│{7: }{23:-----------------}| 211{1:~ }│{1:~ }|*6 212{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 213:set diffopt+=internal | 214]] ) 215 216screen : try_resize ( 40 , 9 ) 217screen : expect ( [[ 218{7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}| 219{7: }5 │{7: }5 | 220{7: }6 │{7: }6 | 221{7: }7 │{7: }7 | 222{7: }8 │{7: }8 | 223{7: }9 │{7: }9 | 224{7: }10 │{7: }10 | 225{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 226| 227]] ) 228end ) 229 230it ( 'Add a line in the middle of file 2, remove on at the end of file 1' , function () 231write_file ( fname , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n' , false ) 232write_file ( fname_2 , '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n' , false ) 233reread () 234 235feed ( ':set diffopt=filler<cr>' ) 236screen : expect ( [[ 237{7: }^1 │{7: }1 | 238{7: }2 │{7: }2 | 239{7: }3 │{7: }3 | 240{7: }4 │{7: }4 | 241{7: }{23:------------------}│{7: }{22:4 }| 242{7: }5 │{7: }5 | 243{7: }6 │{7: }6 | 244{7: }7 │{7: }7 | 245{7: }8 │{7: }8 | 246{7: }9 │{7: }9 | 247{7: }10 │{7: }10 | 248{7: }{22:11 }│{7: }{23:-----------------}| 249{1:~ }│{1:~ }|*2 250{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 251:set diffopt=filler | 252]] ) 253 254feed ( ':set diffopt+=internal<cr>' ) 255screen : expect ( [[ 256{7: }^1 │{7: }1 | 257{7: }2 │{7: }2 | 258{7: }3 │{7: }3 | 259{7: }4 │{7: }4 | 260{7: }{23:------------------}│{7: }{22:4 }| 261{7: }5 │{7: }5 | 262{7: }6 │{7: }6 | 263{7: }7 │{7: }7 | 264{7: }8 │{7: }8 | 265{7: }9 │{7: }9 | 266{7: }10 │{7: }10 | 267{7: }{22:11 }│{7: }{23:-----------------}| 268{1:~ }│{1:~ }|*2 269{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 270:set diffopt+=internal | 271]] ) 272end ) 273 274it ( 'Add a line in the middle of file 1, remove on at the end of file 2' , function () 275write_file ( fname , '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n' , false ) 276write_file ( fname_2 , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n' , false ) 277reread () 278 279feed ( ':set diffopt=filler<cr>' ) 280screen : expect ( [[ 281{7: }^1 │{7: }1 | 282{7: }2 │{7: }2 | 283{7: }3 │{7: }3 | 284{7: }4 │{7: }4 | 285{7: }{22:4 }│{7: }{23:-----------------}| 286{7: }5 │{7: }5 | 287{7: }6 │{7: }6 | 288{7: }7 │{7: }7 | 289{7: }8 │{7: }8 | 290{7: }9 │{7: }9 | 291{7: }10 │{7: }10 | 292{7: }{23:------------------}│{7: }{22:11 }| 293{1:~ }│{1:~ }|*2 294{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 295:set diffopt=filler | 296]] ) 297 298feed ( ':set diffopt+=internal<cr>' ) 299screen : expect ( [[ 300{7: }^1 │{7: }1 | 301{7: }2 │{7: }2 | 302{7: }3 │{7: }3 | 303{7: }4 │{7: }4 | 304{7: }{22:4 }│{7: }{23:-----------------}| 305{7: }5 │{7: }5 | 306{7: }6 │{7: }6 | 307{7: }7 │{7: }7 | 308{7: }8 │{7: }8 | 309{7: }9 │{7: }9 | 310{7: }10 │{7: }10 | 311{7: }{23:------------------}│{7: }{22:11 }| 312{1:~ }│{1:~ }|*2 313{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 314:set diffopt+=internal | 315]] ) 316end ) 317 318describe ( 'normal/patience/histogram diff algorithm' , function () 319setup ( function () 320local f1 =[[#include <stdio.h> 321 322// Frobs foo heartily 323int frobnitz(int foo) 324{ 325int i; 326for(i = 0; i < 10; i++) 327{ 328printf("Your answer is: "); 329printf("%d\n", foo); 330} 331} 332 333int fact(int n) 334{ 335if(n > 1) 336{ 337return fact(n-1) * n; 338} 339return 1; 340} 341 342int main(int argc, char **argv) 343{ 344frobnitz(fact(10)); 345}]] 346write_file ( fname , f1 , false ) 347local f2 =[[#include <stdio.h> 348 349int fib(int n) 350{ 351if(n > 2) 352{ 353return fib(n-1) + fib(n-2); 354} 355return 1; 356} 357 358// Frobs foo heartily 359int frobnitz(int foo) 360{ 361int i; 362for(i = 0; i < 10; i++) 363{ 364printf("%d\n", foo); 365} 366} 367 368int main(int argc, char **argv) 369{ 370frobnitz(fib(10)); 371}]] 372write_file ( fname_2 , f2 , false ) 373end ) 374 375it ( 'diffopt=+algorithm:myers' , function () 376reread () 377feed ( ':set diffopt=internal,filler<cr>' ) 378screen : expect ( [[ 379{7: }^#include <stdio.h>│{7: }#include <stdio.h| 380{7: } │{7: } | 381{7: }{27:// Frobs foo heart}│{7: }{27:int fib(int n)}{4: }| 382{7: }{22:int frobnitz(int f}│{7: }{23:-----------------}| 383{7: }{ │{7: }{ | 384{7: }{4: i}{27:nt i;}{4: }│{7: }{4: i}{27:f(n > 2)}{4: }| 385{7: }{22: for(i = 0; i <}│{7: }{23:-----------------}| 386{7: } { │{7: } { | 387{7: }{4: }{27:printf("Yo}│{7: }{4: }{27:return fi}| 388{7: }{22: printf("%d}│{7: }{23:-----------------}| 389{7: } } │{7: } } | 390{7: }{23:------------------}│{7: }{22: return 1; }| 391{7: }} │{7: }} | 392{7: } │{7: } | 393{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 394:set diffopt=internal,filler | 395]] ) 396 397feed ( 'G' ) 398screen : expect ( [[ 399{7: }{23:------------------}│{7: }{22:int frobnitz(int }| 400{7: }{ │{7: }{ | 401{7: }{4: i}{27:f(n > 1)}{4: }│{7: }{4: i}{27:nt i;}{4: }| 402{7: }{23:------------------}│{7: }{22: for(i = 0; i }| 403{7: } { │{7: } { | 404{7: }{4: }{27:return fac}│{7: }{4: }{27:printf("%}| 405{7: } } │{7: } } | 406{7: }{22: return 1; }│{7: }{23:-----------------}| 407{7: }} │{7: }} | 408{7: } │{7: } | 409{7: }int main(int argc,│{7: }int main(int argc| 410{7: }{ │{7: }{ | 411{7: }{4: frobnitz(f}{27:act}{4:(}│{7: }{4: frobnitz(f}{27:ib}{4:(}| 412{7: }^} │{7: }} | 413{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 414:set diffopt=internal,filler | 415]] ) 416end ) 417 418it ( 'diffopt+=algorithm:patience' , function () 419reread () 420feed ( ':set diffopt=internal,filler,algorithm:patience<cr>' ) 421screen : expect ( [[ 422{7: }^#include <stdio.h>│{7: }#include <stdio.h| 423{7: } │{7: } | 424{7: }{23:------------------}│{7: }{22:int fib(int n) }| 425{7: }{23:------------------}│{7: }{22:{ }| 426{7: }{23:------------------}│{7: }{22: if(n > 2) }| 427{7: }{23:------------------}│{7: }{22: { }| 428{7: }{23:------------------}│{7: }{22: return fi}| 429{7: }{23:------------------}│{7: }{22: } }| 430{7: }{23:------------------}│{7: }{22: return 1; }| 431{7: }{23:------------------}│{7: }{22:} }| 432{7: }{23:------------------}│{7: }{22: }| 433{7: }// Frobs foo heart│{7: }// Frobs foo hear| 434{7: }int frobnitz(int f│{7: }int frobnitz(int | 435{7: }{ │{7: }{ | 436{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 437| 438]] ) 439 440feed ( 'G' ) 441screen : expect ( [[ 442{7: } │{7: } | 443{7: }{22:int fact(int n) }│{7: }{23:-----------------}| 444{7: }{22:{ }│{7: }{23:-----------------}| 445{7: }{22: if(n > 1) }│{7: }{23:-----------------}| 446{7: }{22: { }│{7: }{23:-----------------}| 447{7: }{22: return fac}│{7: }{23:-----------------}| 448{7: }{22: } }│{7: }{23:-----------------}| 449{7: }{22: return 1; }│{7: }{23:-----------------}| 450{7: }{22:} }│{7: }{23:-----------------}| 451{7: }{22: }│{7: }{23:-----------------}| 452{7: }int main(int argc,│{7: }int main(int argc| 453{7: }{ │{7: }{ | 454{7: }{4: frobnitz(f}{27:act}{4:(}│{7: }{4: frobnitz(f}{27:ib}{4:(}| 455{7: }^} │{7: }} | 456{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 457| 458]] ) 459end ) 460 461it ( 'diffopt+=algorithm:histogram' , function () 462reread () 463feed ( ':set diffopt=internal,filler,algorithm:histogram<cr>' ) 464screen : expect ( [[ 465{7: }^#include <stdio.h>│{7: }#include <stdio.h| 466{7: } │{7: } | 467{7: }{23:------------------}│{7: }{22:int fib(int n) }| 468{7: }{23:------------------}│{7: }{22:{ }| 469{7: }{23:------------------}│{7: }{22: if(n > 2) }| 470{7: }{23:------------------}│{7: }{22: { }| 471{7: }{23:------------------}│{7: }{22: return fi}| 472{7: }{23:------------------}│{7: }{22: } }| 473{7: }{23:------------------}│{7: }{22: return 1; }| 474{7: }{23:------------------}│{7: }{22:} }| 475{7: }{23:------------------}│{7: }{22: }| 476{7: }// Frobs foo heart│{7: }// Frobs foo hear| 477{7: }int frobnitz(int f│{7: }int frobnitz(int | 478{7: }{ │{7: }{ | 479{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 480| 481]] ) 482 483feed ( 'G' ) 484screen : expect ( [[ 485{7: } │{7: } | 486{7: }{22:int fact(int n) }│{7: }{23:-----------------}| 487{7: }{22:{ }│{7: }{23:-----------------}| 488{7: }{22: if(n > 1) }│{7: }{23:-----------------}| 489{7: }{22: { }│{7: }{23:-----------------}| 490{7: }{22: return fac}│{7: }{23:-----------------}| 491{7: }{22: } }│{7: }{23:-----------------}| 492{7: }{22: return 1; }│{7: }{23:-----------------}| 493{7: }{22:} }│{7: }{23:-----------------}| 494{7: }{22: }│{7: }{23:-----------------}| 495{7: }int main(int argc,│{7: }int main(int argc| 496{7: }{ │{7: }{ | 497{7: }{4: frobnitz(f}{27:act}{4:(}│{7: }{4: frobnitz(f}{27:ib}{4:(}| 498{7: }^} │{7: }} | 499{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 500| 501]] ) 502end ) 503end ) 504 505describe ( 'diffopt+=indent-heuristic' , function () 506setup ( function () 507local f1 =[[ 508def finalize(values) 509 510values.each do |v| 511v.finalize 512end]] 513write_file ( fname , f1 , false ) 514local f2 =[[ 515def finalize(values) 516 517values.each do |v| 518v.prepare 519end 520 521values.each do |v| 522v.finalize 523end]] 524write_file ( fname_2 , f2 , false ) 525feed ( ':diffupdate!<cr>' ) 526end ) 527 528it ( 'internal' , function () 529reread () 530feed ( ':set diffopt=internal,filler<cr>' ) 531screen : expect ( [[ 532{7: }^def finalize(value│{7: }def finalize(valu| 533{7: } │{7: } | 534{7: } values.each do |│{7: } values.each do | 535{7: }{23:------------------}│{7: }{22: v.prepare }| 536{7: }{23:------------------}│{7: }{22: end }| 537{7: }{23:------------------}│{7: }{22: }| 538{7: }{23:------------------}│{7: }{22: values.each do }| 539{7: } v.finalize │{7: } v.finalize | 540{7: } end │{7: } end | 541{1:~ }│{1:~ }|*5 542{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 543:set diffopt=internal,filler | 544]] ) 545end ) 546 547it ( 'indent-heuristic' , function () 548reread () 549feed ( ':set diffopt=internal,filler,indent-heuristic<cr>' ) 550screen : expect ( [[ 551{7: }^def finalize(value│{7: }def finalize(valu| 552{7: } │{7: } | 553{7: }{23:------------------}│{7: }{22: values.each do }| 554{7: }{23:------------------}│{7: }{22: v.prepare }| 555{7: }{23:------------------}│{7: }{22: end }| 556{7: }{23:------------------}│{7: }{22: }| 557{7: } values.each do |│{7: } values.each do | 558{7: } v.finalize │{7: } v.finalize | 559{7: } end │{7: } end | 560{1:~ }│{1:~ }|*5 561{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 562| 563]] ) 564end ) 565 566it ( 'indent-heuristic random order' , function () 567reread () 568feed ( ':set diffopt=internal,filler,indent-heuristic,algorithm:patience<cr>' ) 569feed ( ':<cr>' ) 570screen : expect ( [[ 571{7: }^def finalize(value│{7: }def finalize(valu| 572{7: } │{7: } | 573{7: }{23:------------------}│{7: }{22: values.each do }| 574{7: }{23:------------------}│{7: }{22: v.prepare }| 575{7: }{23:------------------}│{7: }{22: end }| 576{7: }{23:------------------}│{7: }{22: }| 577{7: } values.each do |│{7: } values.each do | 578{7: } v.finalize │{7: } v.finalize | 579{7: } end │{7: } end | 580{1:~ }│{1:~ }|*5 581{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 582: | 583]] ) 584end ) 585end ) 586 587it ( 'Diff the same file' , function () 588write_file ( fname , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 589write_file ( fname_2 , '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n' , false ) 590reread () 591 592feed ( ':set diffopt=filler<cr>' ) 593screen : expect ( [[ 594{7:+ }{13:^+-- 10 lines: 1···}│{7:+ }{13:+-- 10 lines: 1··}| 595{1:~ }│{1:~ }|*13 596{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 597:set diffopt=filler | 598]] ) 599 600feed ( ':set diffopt+=internal<cr>' ) 601screen : expect ( [[ 602{7:+ }{13:^+-- 10 lines: 1···}│{7:+ }{13:+-- 10 lines: 1··}| 603{1:~ }│{1:~ }|*13 604{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 605:set diffopt+=internal | 606]] ) 607end ) 608 609it ( 'Diff an empty file' , function () 610write_file ( fname , '' , false ) 611write_file ( fname_2 , '' , false ) 612reread () 613 614feed ( ':set diffopt=filler<cr>' ) 615screen : expect ( [[ 616{7:- }^ │{7:- } | 617{1:~ }│{1:~ }|*13 618{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 619:set diffopt=filler | 620]] ) 621 622feed ( ':set diffopt+=internal<cr>' ) 623screen : expect ( [[ 624{7:- }^ │{7:- } | 625{1:~ }│{1:~ }|*13 626{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 627:set diffopt+=internal | 628]] ) 629end ) 630 631it ( 'Diff empty and non-empty file' , function () 632write_file ( fname , '' , false ) 633write_file ( fname_2 , 'foo\nbar\nbaz' , false ) 634reread () 635 636feed ( ':set diffopt=filler<cr>' ) 637screen : expect ( [[ 638{7: }{23:------------------}│{7: }{22:foo }| 639{7: }{23:------------------}│{7: }{22:bar }| 640{7: }{23:------------------}│{7: }{22:baz }| 641{7: }^ │{1:~ }| 642{1:~ }│{1:~ }|*10 643{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 644:set diffopt=filler | 645]] ) 646 647feed ( ':set diffopt+=internal<cr>' ) 648screen : expect ( [[ 649{7: }{23:------------------}│{7: }{22:foo }| 650{7: }{23:------------------}│{7: }{22:bar }| 651{7: }{23:------------------}│{7: }{22:baz }| 652{7: }^ │{1:~ }| 653{1:~ }│{1:~ }|*10 654{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 655:set diffopt+=internal | 656]] ) 657end ) 658 659it ( 'diffopt+=icase' , function () 660write_file ( fname , 'a\nb\ncd\n' , false ) 661write_file ( fname_2 , 'A\nb\ncDe\n' , false ) 662reread () 663 664feed ( ':set diffopt=filler,icase<cr>' ) 665screen : expect ( [[ 666{7: }^a │{7: }A | 667{7: }b │{7: }b | 668{7: }{4:cd }│{7: }{4:cD}{27:e}{4: }| 669{1:~ }│{1:~ }|*11 670{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 671:set diffopt=filler,icase | 672]] ) 673 674feed ( ':set diffopt+=internal<cr>' ) 675screen : expect ( [[ 676{7: }^a │{7: }A | 677{7: }b │{7: }b | 678{7: }{4:cd }│{7: }{4:cD}{27:e}{4: }| 679{1:~ }│{1:~ }|*11 680{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 681:set diffopt+=internal | 682]] ) 683end ) 684 685describe ( 'diffopt+=iwhite' , function () 686setup ( function () 687local f1 ='int main()\n{\n printf("Hello, World!");\n return 0;\n}\n' 688write_file ( fname , f1 , false ) 689local f2 = 690'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n' 691write_file ( fname_2 , f2 , false ) 692feed ( ':diffupdate!<cr>' ) 693end ) 694 695it ( 'external' , function () 696reread () 697feed ( ':set diffopt=filler,iwhite<cr>' ) 698screen : expect ( [[ 699{7: }^int main() │{7: }int main() | 700{7: }{ │{7: }{ | 701{7: }{23:------------------}│{7: }{22: if (0) }| 702{7: }{23:------------------}│{7: }{22: { }| 703{7: } printf("Hello, │{7: } printf("Hel| 704{7: } return 0; │{7: } return 0; | 705{7: }{23:------------------}│{7: }{22: } }| 706{7: }} │{7: }} | 707{1:~ }│{1:~ }|*6 708{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 709:set diffopt=filler,iwhite | 710]] ) 711end ) 712 713it ( 'internal' , function () 714reread () 715feed ( ':set diffopt=filler,iwhite,internal<cr>' ) 716screen : expect ( [[ 717{7: }^int main() │{7: }int main() | 718{7: }{ │{7: }{ | 719{7: }{23:------------------}│{7: }{22: if (0) }| 720{7: }{23:------------------}│{7: }{22: { }| 721{7: } printf("Hello, │{7: } printf("Hel| 722{7: } return 0; │{7: } return 0; | 723{7: }{23:------------------}│{7: }{22: } }| 724{7: }} │{7: }} | 725{1:~ }│{1:~ }|*6 726{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 727:set diffopt=filler,iwhite,internal | 728]] ) 729end ) 730end ) 731 732describe ( 'diffopt+=iblank' , function () 733setup ( function () 734write_file ( fname , 'a\n\n \ncd\nef\nxxx\n' , false ) 735write_file ( fname_2 , 'a\ncd\n\nef\nyyy\n' , false ) 736feed ( ':diffupdate!<cr>' ) 737end ) 738 739it ( 'generic' , function () 740reread () 741feed ( ':set diffopt=internal,filler,iblank<cr>' ) 742screen : expect ( [[ 743{7: }^a │{7: }a | 744{7: }{22: }│{7: }{23:-----------------}|*2 745{7: }cd │{7: }cd | 746{7: }ef │{7: } | 747{7: }{27:xxx}{4: }│{7: }ef | 748{1:~ }│{7: }{27:yyy}{4: }| 749{1:~ }│{1:~ }|*7 750{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 751:set diffopt=internal,filler,iblank | 752]] ) 753end ) 754 755it ( 'diffopt+=iwhite' , function () 756reread () 757feed ( ':set diffopt=internal,filler,iblank,iwhite<cr>' ) 758feed ( ':<cr>' ) 759screen : expect ( [[ 760{7: }^a │{7: }a | 761{7: } │{7: }cd | 762{7: } │{7: } | 763{7: }cd │{7: }ef | 764{7: }ef │{7: }{27:yyy}{4: }| 765{7: }{27:xxx}{4: }│{1:~ }| 766{1:~ }│{1:~ }|*8 767{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 768: | 769]] ) 770end ) 771 772it ( 'diffopt+=iwhiteall' , function () 773reread () 774feed ( ':set diffopt=internal,filler,iblank,iwhiteall<cr>' ) 775feed ( ':<cr>' ) 776screen : expect ( [[ 777{7: }^a │{7: }a | 778{7: } │{7: }cd | 779{7: } │{7: } | 780{7: }cd │{7: }ef | 781{7: }ef │{7: }{27:yyy}{4: }| 782{7: }{27:xxx}{4: }│{1:~ }| 783{1:~ }│{1:~ }|*8 784{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 785: | 786]] ) 787end ) 788 789it ( 'diffopt+=iwhiteeol' , function () 790reread () 791feed ( ':set diffopt=internal,filler,iblank,iwhiteeol<cr>' ) 792feed ( ':<cr>' ) 793screen : expect ( [[ 794{7: }^a │{7: }a | 795{7: } │{7: }cd | 796{7: } │{7: } | 797{7: }cd │{7: }ef | 798{7: }ef │{7: }{27:yyy}{4: }| 799{7: }{27:xxx}{4: }│{1:~ }| 800{1:~ }│{1:~ }|*8 801{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 802: | 803]] ) 804end ) 805end ) 806 807describe ( 'diffopt+=iwhite{eol,all}' , function () 808setup ( function () 809write_file ( fname , 'a \nx\ncd\nef\nxx xx\nfoo\nbar\n' , false ) 810write_file ( fname_2 , 'a\nx\nc d\n ef\nxx xx\nfoo\n\nbar\n' , false ) 811feed ( ':diffupdate!<cr>' ) 812end ) 813 814it ( 'diffopt+=iwhiteeol' , function () 815reread () 816feed ( ':set diffopt=internal,filler,iwhiteeol<cr>' ) 817feed ( ':<cr>' ) 818screen : expect ( [[ 819{7: }^a │{7: }a | 820{7: }x │{7: }x | 821{7: }{4:cd }│{7: }{4:c}{27: }{4:d }| 822{7: }{4:ef }│{7: }{27: }{4:ef }| 823{7: }{4:xx }{27: }{4:xx }│{7: }{4:xx xx }| 824{7: }foo │{7: }foo | 825{7: }{23:------------------}│{7: }{22: }| 826{7: }bar │{7: }bar | 827{1:~ }│{1:~ }|*6 828{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 829: | 830]] ) 831end ) 832 833it ( 'diffopt+=iwhiteall' , function () 834reread () 835feed ( ':set diffopt=internal,filler,iwhiteall<cr>' ) 836feed ( ':<cr>' ) 837screen : expect ( [[ 838{7: }^a │{7: }a | 839{7: }x │{7: }x | 840{7: }cd │{7: }c d | 841{7: }ef │{7: } ef | 842{7: }xx xx │{7: }xx xx | 843{7: }foo │{7: }foo | 844{7: }{23:------------------}│{7: }{22: }| 845{7: }bar │{7: }bar | 846{1:~ }│{1:~ }|*6 847{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 848: | 849]] ) 850end ) 851end ) 852 853-- oldtest: Test_diff_scroll() 854-- This was scrolling for 'cursorbind' but 'scrollbind' is more important 855it ( 'scrolling works correctly vim-patch:8.2.5155' , function () 856screen : try_resize ( 40 , 12 ) 857write_file ( 858fname , 859dedent ( [[ 860line 1 861line 2 862line 3 863line 4 864 865// Common block 866// one 867// containing 868// four lines 869 870// Common block 871// two 872// containing 873// four lines]] ), 874false 875) 876write_file ( 877fname_2 , 878dedent ( [[ 879line 1 880line 2 881line 3 882line 4 883 884Lorem 885ipsum 886dolor 887sit 888amet, 889consectetur 890adipiscing 891elit. 892Etiam 893luctus 894lectus 895sodales, 896dictum 897 898// Common block 899// one 900// containing 901// four lines 902 903Vestibulum 904tincidunt 905aliquet 906nulla. 907 908// Common block 909// two 910// containing 911// four lines]] ), 912false 913) 914reread () 915 916feed ( '<C-W><C-W>jjjj' ) 917screen : expect ( [[ 918{7: }line 1 │{7: }line 1 | 919{7: }line 2 │{7: }line 2 | 920{7: }line 3 │{7: }line 3 | 921{7: }line 4 │{7: }line 4 | 922{7: } │{7: }^ | 923{7: }{23:-----------------}│{7: }{22:Lorem }| 924{7: }{23:-----------------}│{7: }{22:ipsum }| 925{7: }{23:-----------------}│{7: }{22:dolor }| 926{7: }{23:-----------------}│{7: }{22:sit }| 927{7: }{23:-----------------}│{7: }{22:amet, }| 928{2:<nal-diff-screen-1 }{3:<al-diff-screen-1.2 }| 929:e | 930]] ) 931feed ( 'j' ) 932screen : expect ( [[ 933{7: }line 1 │{7: }line 1 | 934{7: }line 2 │{7: }line 2 | 935{7: }line 3 │{7: }line 3 | 936{7: }line 4 │{7: }line 4 | 937{7: } │{7: } | 938{7: }{23:-----------------}│{7: }{22:^Lorem }| 939{7: }{23:-----------------}│{7: }{22:ipsum }| 940{7: }{23:-----------------}│{7: }{22:dolor }| 941{7: }{23:-----------------}│{7: }{22:sit }| 942{7: }{23:-----------------}│{7: }{22:amet, }| 943{2:<nal-diff-screen-1 }{3:<al-diff-screen-1.2 }| 944:e | 945]] ) 946end ) 947 948describe ( 'line matching diff algorithm' , function () 949setup ( function () 950local f1 =[[if __name__ == "__main__": 951import sys 952app = QWidgets.QApplication(sys.args) 953MainWindow = QtWidgets.QMainWindow() 954ui = UI_MainWindow() 955ui.setupUI(MainWindow) 956MainWindow.show() 957sys.exit(app.exec_())]] 958write_file ( fname , f1 , false ) 959local f2 =[[if __name__ == "__main__": 960import sys 961comment these things 962#app = QWidgets.QApplication(sys.args) 963#MainWindow = QtWidgets.QMainWindow() 964add a completely different line here 965#ui = UI_MainWindow() 966add another new line 967ui.setupUI(MainWindow) 968MainWindow.show() 969sys.exit(app.exec_())]] 970write_file ( fname_2 , f2 , false ) 971end ) 972 973it ( 'diffopt+=linematch:20' , function () 974reread () 975feed ( ':set diffopt=internal,filler<cr>' ) 976screen : expect ( [[ 977{7: }^if __name__ == "__│{7: }if __name__ == "_| 978{7: } import sys │{7: } import sys | 979{7: }{4: }{27:app = QWidgets}│{7: }{4: }{27:comment these}| 980{7: }{4: }{27:MainWindow = Q}│{7: }{4: }{27:#app = QWidge}| 981{7: }{4: }{27:ui = UI_}{4:MainWi}│{7: }{4: }{27:#MainWindow =}| 982{7: }{23:------------------}│{7: }{22: add a complet}| 983{7: }{23:------------------}│{7: }{22: #ui = UI_Main}| 984{7: }{23:------------------}│{7: }{22: add another n}| 985{7: } ui.setupUI(Mai│{7: } ui.setupUI(Ma| 986{7: } MainWindow.sho│{7: } MainWindow.sh| 987{7: } sys.exit(app.e│{7: } sys.exit(app.| 988{1:~ }│{1:~ }|*3 989{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 990:set diffopt=internal,filler | 991]] ) 992 993feed ( 'G' ) 994feed ( ':set diffopt+=linematch:20<cr>' ) 995screen : expect ( [[ 996{7: }if __name__ == "__│{7: }if __name__ == "_| 997{7: } import sys │{7: } import sys | 998{7: }{23:------------------}│{7: }{22: comment these}| 999{7: }{4: app = QWidgets}│{7: }{4: }{27:#}{4:app = QWidge}| 1000{7: }{4: MainWindow = Q}│{7: }{4: }{27:#}{4:MainWindow =}| 1001{7: }{23:------------------}│{7: }{22: add a complet}| 1002{7: }{4: ui = UI_MainWi}│{7: }{4: }{27:#}{4:ui = UI_Main}| 1003{7: }{23:------------------}│{7: }{22: add another n}| 1004{7: } ui.setupUI(Mai│{7: } ui.setupUI(Ma| 1005{7: } MainWindow.sho│{7: } MainWindow.sh| 1006{7: } ^sys.exit(app.e│{7: } sys.exit(app.| 1007{1:~ }│{1:~ }|*3 1008{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 1009:set diffopt+=linematch:20 | 1010]] ) 1011end ) 1012end ) 1013 1014describe ( 'line matching diff algorithm with icase' , function () 1015setup ( function () 1016local f1 =[[DDD 1017_aa]] 1018write_file ( fname , f1 , false ) 1019local f2 =[[DDD 1020AAA 1021ccca]] 1022write_file ( fname_2 , f2 , false ) 1023end ) 1024it ( 'diffopt+=linematch:20,icase' , function () 1025reread () 1026feed ( ':set diffopt=internal,filler,linematch:20<cr>' ) 1027screen : expect ( [[ 1028{7: }^DDD │{7: }DDD | 1029{7: }{23:------------------}│{7: }{22:AAA }| 1030{7: }{27:_a}{4:a }│{7: }{27:ccc}{4:a }| 1031{1:~ }│{1:~ }|*11 1032{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 1033| 1034]] ) 1035feed ( ':set diffopt+=icase<cr>' ) 1036screen : expect ( [[ 1037{7: }^DDD │{7: }DDD | 1038{7: }{27:_}{4:aa }│{7: }{27:A}{4:AA }| 1039{7: }{23:------------------}│{7: }{22:ccca }| 1040{1:~ }│{1:~ }|*11 1041{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 1042:set diffopt+=icase | 1043]] ) 1044end ) 1045end ) 1046 1047describe ( 'line matching diff algorithm with iwhiteall' , function () 1048setup ( function () 1049local f1 =[[BB 1050AAA]] 1051write_file ( fname , f1 , false ) 1052local f2 =[[BB 1053AAB 1054AAAB]] 1055write_file ( fname_2 , f2 , false ) 1056end ) 1057it ( 'diffopt+=linematch:20,iwhiteall' , function () 1058reread () 1059feed ( ':set diffopt=internal,filler,linematch:20<cr>' ) 1060screen : expect { 1061grid =[[ 1062{7: }^BB │{7: }BB | 1063{7: }{4: AA}{27:A}{4: }│{7: }{4: AA}{27:B}{4: }| 1064{7: }{23:------------------}│{7: }{22:AAAB }| 1065{1:~ }│{1:~ }|*11 1066{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 1067| 1068]] , 1069} 1070feed ( ':set diffopt+=iwhiteall<cr>' ) 1071screen : expect { 1072grid =[[ 1073{7: }^BB │{7: }BB | 1074{7: }{23:------------------}│{7: }{22: AAB }| 1075{7: }{4: AAA }│{7: }{4:AAA}{27:B}{4: }| 1076{1:~ }│{1:~ }|*11 1077{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }| 1078:set diffopt+=iwhiteall | 1079]] , 1080} 1081end ) 1082end ) 1083 1084it ( 'redraws with a change to non-current buffer' , function () 1085write_file ( fname , 'aaa\nbbb\nccc\n\nxx' , false ) 1086write_file ( fname_2 , 'aaa\nbbb\nccc\n\nyy' , false ) 1087reread () 1088local buf =api . nvim_get_current_buf () 1089command ( 'botright new' ) 1090screen : expect { 1091grid =[[ 1092{7: }aaa │{7: }aaa | 1093{7: }bbb │{7: }bbb | 1094{7: }ccc │{7: }ccc | 1095{7: } │{7: } | 1096{7: }{27:xx}{4: }│{7: }{27:yy}{4: }| 1097{1:~ }│{1:~ }| 1098{2:<onal-diff-screen-1 <l-diff-screen-1.2 }| 1099^ | 1100{1:~ }|*6 1101{3:[No Name] }| 1102:e | 1103]] , 1104} 1105 1106api . nvim_buf_set_lines ( buf , 1 , 2 , true , { 'BBB' } ) 1107screen : expect { 1108grid =[[ 1109{7: }aaa │{7: }aaa | 1110{7: }{27:BBB}{4: }│{7: }{27:bbb}{4: }| 1111{7: }ccc │{7: }ccc | 1112{7: } │{7: } | 1113{7: }{27:xx}{4: }│{7: }{27:yy}{4: }| 1114{1:~ }│{1:~ }| 1115{2:<-diff-screen-1 [+] <l-diff-screen-1.2 }| 1116^ | 1117{1:~ }|*6 1118{3:[No Name] }| 1119:e | 1120]] , 1121} 1122end ) 1123 1124it ( 'redraws with a change current buffer in another window' , function () 1125write_file ( fname , 'aaa\nbbb\nccc\n\nxx' , false ) 1126write_file ( fname_2 , 'aaa\nbbb\nccc\n\nyy' , false ) 1127reread () 1128local buf =api . nvim_get_current_buf () 1129command ( 'botright split | diffoff' ) 1130screen : expect { 1131grid =[[ 1132{7: }aaa │{7: }aaa | 1133{7: }bbb │{7: }bbb | 1134{7: }ccc │{7: }ccc | 1135{7: } │{7: } | 1136{7: }{27:xx}{4: }│{7: }{27:yy}{4: }| 1137{1:~ }│{1:~ }| 1138{2:<onal-diff-screen-1 <l-diff-screen-1.2 }| 1139^aaa | 1140bbb | 1141ccc | 1142| 1143xx | 1144{1:~ }|*2 1145{3:Xtest-functional-diff-screen-1 }| 1146:e | 1147]] , 1148} 1149 1150api . nvim_buf_set_lines ( buf , 1 , 2 , true , { 'BBB' } ) 1151screen : expect { 1152grid =[[ 1153{7: }aaa │{7: }aaa | 1154{7: }{27:BBB}{4: }│{7: }{27:bbb}{4: }| 1155{7: }ccc │{7: }ccc | 1156{7: } │{7: } | 1157{7: }{27:xx}{4: }│{7: }{27:yy}{4: }| 1158{1:~ }│{1:~ }| 1159{2:<-diff-screen-1 [+] <l-diff-screen-1.2 }| 1160^aaa | 1161BBB | 1162ccc | 1163| 1164xx | 1165{1:~ }|*2 1166{3:Xtest-functional-diff-screen-1 [+] }| 1167:e | 1168]] , 1169} 1170end ) 1171end ) 1172 1173it ( 'win_update redraws lines properly' , function () 1174local screen 1175screen =Screen . new ( 50 , 10 ) 1176screen : set_default_attr_ids ( { 1177[ 1 ] ={ bold =true , foreground =Screen . colors . Blue1 } , 1178[ 2 ] ={ foreground =Screen . colors . Grey100 , background =Screen . colors . Red } , 1179[ 3 ] ={ 1180background =Screen . colors . Red , 1181foreground =Screen . colors . Grey100 , 1182special =Screen . colors . Yellow , 1183} , 1184[ 4 ] ={ bold =true , foreground =Screen . colors . SeaGreen4 } , 1185[ 5 ] ={ special =Screen . colors . Yellow } , 1186[ 6 ] ={ special =Screen . colors . Yellow , bold =true , foreground =Screen . colors . SeaGreen4 } , 1187[ 7 ] ={ foreground =Screen . colors . Grey0 , background =Screen . colors . Grey100 } , 1188[ 8 ] ={ foreground =Screen . colors . Gray90 , background =Screen . colors . Grey100 } , 1189[ 9 ] ={ foreground =tonumber ( '0x00000c' ), background =Screen . colors . Grey100 } , 1190[ 10 ] ={ background =Screen . colors . Grey100 , bold =true , foreground =tonumber ( '0xe5e5ff' ) } , 1191[ 11 ] ={ background =Screen . colors . Grey100 , bold =true , foreground =tonumber ( '0x2b8452' ) } , 1192[ 12 ] ={ bold =true , reverse =true } , 1193[ 13 ] ={ foreground =Screen . colors . DarkBlue , background =Screen . colors . WebGray } , 1194[ 14 ] ={ reverse =true } , 1195[ 15 ] ={ background =Screen . colors . LightBlue } , 1196[ 16 ] ={ background =Screen . colors . LightCyan1 , bold =true , foreground =Screen . colors . Blue1 } , 1197[ 17 ] ={ bold =true , background =Screen . colors . Red } , 1198[ 18 ] ={ background =Screen . colors . LightMagenta } , 1199} ) 1200 1201insert ( [[ 12021 1203 1204 12052 12061a 1207]] ) 1208command ( 'vnew left' ) 1209insert ( [[ 12102 12112a 12122b 1213]] ) 1214command ( 'windo diffthis' ) 1215command ( 'windo 1' ) 1216screen : expect { 1217grid =[[ 1218{13: }{16:-----------------------}│{13: }{15:^1 }| 1219{13: }{16:-----------------------}│{13: }{15: }|*2 1220{13: }2 │{13: }2 | 1221{13: }{17:2}{18:a }│{13: }{17:1}{18:a }| 1222{13: }{15:2b }│{13: }{16:----------------------}| 1223{13: } │{13: } | 1224{1:~ }│{1:~ }| 1225{14:left [+] }{12:[No Name] [+] }| 1226| 1227]] , 1228} 1229feed ( '<C-e>' ) 1230feed ( '<C-e>' ) 1231feed ( '<C-y>' ) 1232feed ( '<C-y>' ) 1233feed ( '<C-y>' ) 1234screen : expect { 1235grid =[[ 1236{13: }{16:-----------------------}│{13: }{15:1 }| 1237{13: }{16:-----------------------}│{13: }{15: }| 1238{13: }{16:-----------------------}│{13: }{15:^ }| 1239{13: }2 │{13: }2 | 1240{13: }{17:2}{18:a }│{13: }{17:1}{18:a }| 1241{13: }{15:2b }│{13: }{16:----------------------}| 1242{13: } │{13: } | 1243{1:~ }│{1:~ }| 1244{14:left [+] }{12:[No Name] [+] }| 1245| 1246]] , 1247} 1248end ) 1249 1250-- oldtest: Test_diff_rnu() 1251it ( 'diff updates line numbers below filler lines' , function () 1252local screen =Screen . new ( 40 , 14 ) 1253exec ( [[ 1254set diffopt=internal,filler 1255call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b']) 1256vnew 1257call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b']) 1258windo diffthis 1259setlocal number rnu cursorline cursorlineopt=number foldcolumn=0 1260]] ) 1261screen : expect ( [[ 1262{7: }a │{15:1 }^a | 1263{7: }a │{8: 1 }a | 1264{7: }a │{8: 2 }a | 1265{7: }{27:x}{4: }│{8: 3 }{27:y}{4: }| 1266{7: }{22:x }│{8: }{23:----------------}|*2 1267{7: }b │{8: 4 }b | 1268{7: }b │{8: 5 }b | 1269{7: }b │{8: 6 }b | 1270{7: }b │{8: 7 }b | 1271{7: }b │{8: 8 }b | 1272{1:~ }│{1:~ }| 1273{2:[No Name] [+] }{3:[No Name] [+] }| 1274| 1275]] ) 1276feed ( 'j' ) 1277screen : expect ( [[ 1278{7: }a │{8: 1 }a | 1279{7: }a │{15:2 }^a | 1280{7: }a │{8: 1 }a | 1281{7: }{27:x}{4: }│{8: 2 }{27:y}{4: }| 1282{7: }{22:x }│{8: }{23:----------------}|*2 1283{7: }b │{8: 3 }b | 1284{7: }b │{8: 4 }b | 1285{7: }b │{8: 5 }b | 1286{7: }b │{8: 6 }b | 1287{7: }b │{8: 7 }b | 1288{1:~ }│{1:~ }| 1289{2:[No Name] [+] }{3:[No Name] [+] }| 1290| 1291]] ) 1292feed ( 'j' ) 1293screen : expect ( [[ 1294{7: }a │{8: 2 }a | 1295{7: }a │{8: 1 }a | 1296{7: }a │{15:3 }^a | 1297{7: }{27:x}{4: }│{8: 1 }{27:y}{4: }| 1298{7: }{22:x }│{8: }{23:----------------}|*2 1299{7: }b │{8: 2 }b | 1300{7: }b │{8: 3 }b | 1301{7: }b │{8: 4 }b | 1302{7: }b │{8: 5 }b | 1303{7: }b │{8: 6 }b | 1304{1:~ }│{1:~ }| 1305{2:[No Name] [+] }{3:[No Name] [+] }| 1306| 1307]] ) 1308end ) 1309 1310-- oldtest: Test_diff_with_scroll_and_change() 1311it ( 'Align the filler lines when changing text in diff mode' , function () 1312local screen =Screen . new ( 40 , 20 ) 1313exec ( [[ 1314call setline(1, range(1, 15)) 1315vnew 1316call setline(1, range(9, 15)) 1317windo diffthis 1318wincmd h 1319exe "normal Gl5\<C-E>" 1320]] ) 1321screen : expect { 1322grid =[[ 1323{7: }{23:------------------}│{7: }{22:6 }| 1324{7: }{23:------------------}│{7: }{22:7 }| 1325{7: }{23:------------------}│{7: }{22:8 }| 1326{7: }9 │{7: }9 | 1327{7: }10 │{7: }10 | 1328{7: }11 │{7: }11 | 1329{7: }12 │{7: }12 | 1330{7: }13 │{7: }13 | 1331{7: }14 │{7: }14 | 1332{7:- }1^5 │{7:- }15 | 1333{1:~ }│{1:~ }|*8 1334{3:[No Name] [+] }{2:[No Name] [+] }| 1335| 1336]] , 1337} 1338feed ( 'ax<Esc>' ) 1339screen : expect { 1340grid =[[ 1341{7: }{23:------------------}│{7: }{22:6 }| 1342{7: }{23:------------------}│{7: }{22:7 }| 1343{7: }{23:------------------}│{7: }{22:8 }| 1344{7: }9 │{7: }9 | 1345{7: }10 │{7: }10 | 1346{7: }11 │{7: }11 | 1347{7: }12 │{7: }12 | 1348{7: }13 │{7: }13 | 1349{7: }14 │{7: }14 | 1350{7: }{4:15}{27:^x}{4: }│{7: }{4:15 }| 1351{1:~ }│{1:~ }|*8 1352{3:[No Name] [+] }{2:[No Name] [+] }| 1353| 1354]] , 1355} 1356feed ( '<C-W>lay<Esc>' ) 1357screen : expect { 1358grid =[[ 1359{7: }{23:-----------------}│{7: }{22:6 }| 1360{7: }{23:-----------------}│{7: }{22:7 }| 1361{7: }{23:-----------------}│{7: }{22:8 }| 1362{7: }9 │{7: }9 | 1363{7: }10 │{7: }10 | 1364{7: }11 │{7: }11 | 1365{7: }12 │{7: }12 | 1366{7: }13 │{7: }13 | 1367{7: }14 │{7: }14 | 1368{7: }{4:15}{27:x}{4: }│{7: }{4:15}{27:^y}{4: }| 1369{1:~ }│{1:~ }|*8 1370{2:[No Name] [+] }{3:[No Name] [+] }| 1371| 1372]] , 1373} 1374end ) 1375 1376it ( "diff mode doesn't restore invalid 'foldcolumn' value #21647" , function () 1377local screen =Screen . new ( 60 , 6 ) 1378eq ( '0' , api . nvim_get_option_value ( 'foldcolumn' , {} )) 1379command ( 'diffsplit | bd' ) 1380screen : expect ( [[ 1381^ | 1382{1:~ }|*4 1383| 1384]] ) 1385eq ( '0' , api . nvim_get_option_value ( 'foldcolumn' , {} )) 1386end ) 1387 1388it ( "'relativenumber' doesn't draw beyond end of window in diff mode #29403" , function () 1389local screen =Screen . new ( 60 , 12 ) 1390command ( 'set diffopt=internal,filler,closeoff' ) 1391command ( 'set relativenumber' ) 1392feed ( '10aa<CR><Esc>gg' ) 1393command ( 'vnew' ) 1394feed ( 'ab<CR><Esc>gg' ) 1395command ( 'windo diffthis' ) 1396command ( 'wincmd |' ) 1397screen : expect ( [[ 1398{8: }│{7: }{8: 0 }{27:^a}{4: }| 1399{8: }│{7: }{8: 1 }{22:a }| 1400{8: }│{7: }{8: 2 }{22:a }| 1401{8: }│{7: }{8: 3 }{22:a }| 1402{8: }│{7: }{8: 4 }{22:a }| 1403{8: }│{7: }{8: 5 }{22:a }| 1404{8: }│{7: }{8: 6 }{22:a }| 1405{8: }│{7: }{8: 7 }{22:a }| 1406{8: }│{7: }{8: 8 }{22:a }| 1407{8: }│{7: }{8: 9 }{22:a }| 1408{2:< }{3:[No Name] [+] }| 1409| 1410]] ) 1411feed ( 'j' ) 1412screen : expect ( [[ 1413{8: }│{7: }{8: 1 }{27:a}{4: }| 1414{8: }│{7: }{8: 0 }{22:^a }| 1415{8: }│{7: }{8: 1 }{22:a }| 1416{8: }│{7: }{8: 2 }{22:a }| 1417{8: }│{7: }{8: 3 }{22:a }| 1418{8: }│{7: }{8: 4 }{22:a }| 1419{8: }│{7: }{8: 5 }{22:a }| 1420{8: }│{7: }{8: 6 }{22:a }| 1421{8: }│{7: }{8: 7 }{22:a }| 1422{8: }│{7: }{8: 8 }{22:a }| 1423{2:< }{3:[No Name] [+] }| 1424| 1425]] ) 1426end ) 1427 1428-- oldtest: Test_diff_binary() 1429it ( 'diff mode works properly if file contains NUL bytes vim-patch:8.2.3925' , function () 1430local screen =Screen . new ( 40 , 20 ) 1431screen : add_extra_attr_ids { 1432[ 100 ] ={ foreground =Screen . colors . Blue , bold =true , background =Screen . colors . Red } , 1433} 1434exec ( [[ 1435call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g']) 1436vnew 1437call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g']) 1438windo diffthis 1439wincmd p 1440norm! gg0 1441redraw! 1442]] ) 1443 1444-- Test using internal diff 1445screen : expect ( [[ 1446{7: }{27:^A}{4: }│{7: }{27:a}{4: }| 1447{7: }b │{7: }b | 1448{7: }{4:c }│{7: }{4:c}{100:^@}{4: }| 1449{7: }d │{7: }d | 1450{7: }{27:E}{4: }│{7: }{27:e}{4: }| 1451{7: }f │{7: }f | 1452{7: }g │{7: }g | 1453{1:~ }│{1:~ }|*11 1454{3:[No Name] [+] }{2:[No Name] [+] }| 1455| 1456]] ) 1457 1458-- Test using internal diff and case folding 1459command ( 'set diffopt+=icase' ) 1460feed ( '<C-L>' ) 1461screen : expect ( [[ 1462{7: }^A │{7: }a | 1463{7: }b │{7: }b | 1464{7: }{4:c }│{7: }{4:c}{100:^@}{4: }| 1465{7: }d │{7: }d | 1466{7: }E │{7: }e | 1467{7: }f │{7: }f | 1468{7: }g │{7: }g | 1469{1:~ }│{1:~ }|*11 1470{3:[No Name] [+] }{2:[No Name] [+] }| 1471| 1472]] ) 1473 1474-- Test using external diff 1475command ( 'set diffopt=filler' ) 1476feed ( '<C-L>' ) 1477screen : expect ( [[ 1478{7: }{27:^A}{4: }│{7: }{27:a}{4: }| 1479{7: }b │{7: }b | 1480{7: }{4:c }│{7: }{4:c}{100:^@}{4: }| 1481{7: }d │{7: }d | 1482{7: }{27:E}{4: }│{7: }{27:e}{4: }| 1483{7: }f │{7: }f | 1484{7: }g │{7: }g | 1485{1:~ }│{1:~ }|*11 1486{3:[No Name] [+] }{2:[No Name] [+] }| 1487| 1488]] ) 1489 1490-- Test using external diff and case folding 1491command ( 'set diffopt+=filler,icase' ) 1492feed ( '<C-L>' ) 1493screen : expect ( [[ 1494{7: }^A │{7: }a | 1495{7: }b │{7: }b | 1496{7: }{4:c }│{7: }{4:c}{100:^@}{4: }| 1497{7: }d │{7: }d | 1498{7: }E │{7: }e | 1499{7: }f │{7: }f | 1500{7: }g │{7: }g | 1501{1:~ }│{1:~ }|*11 1502{3:[No Name] [+] }{2:[No Name] [+] }| 1503| 1504]] ) 1505end ) 1506 1507-- oldtest: Test_diff_breakindent_after_filler() 1508it ( "diff mode draws 'breakindent' correctly after filler lines" , function () 1509local screen =Screen . new ( 45 , 8 ) 1510exec ( [[ 1511set laststatus=0 diffopt+=followwrap breakindent breakindentopt=min:0 1512call setline(1, ['a', ' ' .. repeat('c', 50)]) 1513vnew 1514call setline(1, ['a', 'b', ' ' .. repeat('c', 50)]) 1515windo diffthis 1516norm! G$ 1517]] ) 1518screen : expect ( [[ 1519{7: }a │{7: }a | 1520{7: }{22:b }│{7: }{23:--------------------}| 1521{7: } cccccccccccccccccc│{7: } cccccccccccccccccc|*2 1522{7: } cccccccccccccc │{7: } ccccccccccccc^c | 1523{1:~ }│{1:~ }|*2 1524| 1525]] ) 1526end ) 1527 1528-- oldtest: Test_diff_overlapped_diff_blocks_will_be_merged() 1529it ( 'diff mode overlapped diff blocks will be merged' , function () 1530write_file ( 'Xdifile1' , '' ) 1531write_file ( 'Xdifile2' , '' ) 1532write_file ( 'Xdifile3' , '' ) 1533 1534finally ( function () 1535os . remove ( 'Xdifile1' ) 1536os . remove ( 'Xdifile2' ) 1537os . remove ( 'Xdifile3' ) 1538os . remove ( 'Xdiin1' ) 1539os . remove ( 'Xdinew1' ) 1540os . remove ( 'Xdiout1' ) 1541os . remove ( 'Xdiin2' ) 1542os . remove ( 'Xdinew2' ) 1543os . remove ( 'Xdiout2' ) 1544end ) 1545 1546exec ( [[ 1547func DiffExprStub() 1548let txt_in = readfile(v:fname_in) 1549let txt_new = readfile(v:fname_new) 1550if txt_in == ["line1"] && txt_new == ["line2"] 1551call writefile(["1c1"], v:fname_out) 1552elseif txt_in == readfile("Xdiin1") && txt_new == readfile("Xdinew1") 1553call writefile(readfile("Xdiout1"), v:fname_out) 1554elseif txt_in == readfile("Xdiin2") && txt_new == readfile("Xdinew2") 1555call writefile(readfile("Xdiout2"), v:fname_out) 1556endif 1557endfunc 1558]] ) 1559 1560local screen =Screen . new ( 35 , 20 ) 1561command ( 'set winwidth=10 diffopt=filler,internal' ) 1562command ( 'args Xdifile1 Xdifile2 | vert all | windo diffthis' ) 1563 1564WriteDiffFiles ( 'a\nb' , 'x\nx' ) 1565write_file ( 'Xdiin1' , 'a\nb' ) 1566write_file ( 'Xdinew1' , 'x\nx' ) 1567write_file ( 'Xdiout1' , '1c1\n2c2' ) 1568command ( 'set diffexpr=DiffExprStub()' ) 1569screen : expect ( [[ 1570{7: }{27:a}{4: }│{7: }{27:^x}{4: }| 1571{7: }{27:b}{4: }│{7: }{27:x}{4: }| 1572{1:~ }│{1:~ }|*16 1573{2:Xdifile1 }{3:Xdifile2 }| 1574| 1575]] ) 1576command ( 'set diffexpr&' ) 1577 1578WriteDiffFiles ( 'a\nb\nc' , 'x\nc' ) 1579write_file ( 'Xdiin1' , 'a\nb\nc' ) 1580write_file ( 'Xdinew1' , 'x\nc' ) 1581write_file ( 'Xdiout1' , '1c1\n2c1' ) 1582command ( 'set diffexpr=DiffExprStub()' ) 1583screen : expect ( [[ 1584{7: }{27:a}{4: }│{7: }{27:^x}{4: }| 1585{7: }{22:b }│{7: }{23:---------------}| 1586{7: }c │{7: }c | 1587{1:~ }│{1:~ }|*15 1588{2:Xdifile1 }{3:Xdifile2 }| 1589| 1590]] ) 1591command ( 'set diffexpr&' ) 1592 1593WriteDiffFiles ( 'a\nc' , 'x\nx\nc' ) 1594write_file ( 'Xdiin1' , 'a\nc' ) 1595write_file ( 'Xdinew1' , 'x\nx\nc' ) 1596write_file ( 'Xdiout1' , '1c1\n1a2' ) 1597command ( 'set diffexpr=DiffExprStub()' ) 1598screen : expect ( [[ 1599{7: }{27:a}{4: }│{7: }{27:^x}{4: }| 1600{7: }{23:---------------}│{7: }{22:x }| 1601{7: }c │{7: }c | 1602{1:~ }│{1:~ }|*15 1603{2:Xdifile1 }{3:Xdifile2 }| 1604| 1605]] ) 1606command ( 'set diffexpr&' ) 1607 1608command ( 'args Xdifile1 Xdifile2 Xdifile3 | vert all | windo diffthis' ) 1609 1610WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'y\nb\nc' ) 1611screen : expect ( [[ 1612{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }| 1613{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 1614{7: }c │{7: }c │{7: }c | 1615{1:~ }│{1:~ }│{1:~ }|*15 1616{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1617| 1618]] ) 1619 1620WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'a\ny\nc' ) 1621screen : expect ( [[ 1622{7: }a │{7: }a │{7: }^a | 1623{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1624{7: }c │{7: }c │{7: }c | 1625{1:~ }│{1:~ }│{1:~ }|*15 1626{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1627| 1628]] ) 1629 1630WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'a\nb\ny' ) 1631screen : expect ( [[ 1632{7: }a │{7: }a │{7: }^a | 1633{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 1634{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1635{1:~ }│{1:~ }│{1:~ }|*15 1636{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1637| 1638]] ) 1639 1640WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'y\ny\nc' ) 1641screen : expect ( [[ 1642{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }| 1643{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1644{7: }c │{7: }c │{7: }c | 1645{1:~ }│{1:~ }│{1:~ }|*15 1646{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1647| 1648]] ) 1649 1650WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'a\ny\ny' ) 1651screen : expect ( [[ 1652{7: }a │{7: }a │{7: }^a | 1653{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1654{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1655{1:~ }│{1:~ }│{1:~ }|*15 1656{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1657| 1658]] ) 1659 1660WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'y\ny\ny' ) 1661screen : expect ( [[ 1662{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }| 1663{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1664{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1665{1:~ }│{1:~ }│{1:~ }|*15 1666{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1667| 1668]] ) 1669 1670WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nx' , 'y\ny\nc' ) 1671screen : expect ( [[ 1672{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }| 1673{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1674{7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:c}{4: }| 1675{1:~ }│{1:~ }│{1:~ }|*15 1676{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1677| 1678]] ) 1679 1680WriteDiffFiles3 ( 'a\nb\nc' , 'x\nx\nc' , 'a\ny\ny' ) 1681screen : expect ( [[ 1682{7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^a}{4: }| 1683{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1684{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1685{1:~ }│{1:~ }│{1:~ }|*15 1686{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1687| 1688]] ) 1689 1690WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'y\ny\ny\nd\ne' ) 1691screen : expect ( [[ 1692{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }| 1693{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1694{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1695{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }| 1696{7: }e │{7: }e │{7: }e | 1697{1:~ }│{1:~ }│{1:~ }|*13 1698{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1699| 1700]] ) 1701 1702WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'y\ny\ny\ny\ne' ) 1703screen : expect ( [[ 1704{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }| 1705{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1706{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1707{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1708{7: }e │{7: }e │{7: }e | 1709{1:~ }│{1:~ }│{1:~ }|*13 1710{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1711| 1712]] ) 1713 1714WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'y\ny\ny\ny\ny' ) 1715screen : expect ( [[ 1716{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }| 1717{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1718{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1719{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1720{7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:y}{4: }| 1721{1:~ }│{1:~ }│{1:~ }|*13 1722{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1723| 1724]] ) 1725 1726WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\ny\ny\nd\ne' ) 1727screen : expect ( [[ 1728{7: }a │{7: }a │{7: }^a | 1729{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1730{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1731{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }| 1732{7: }e │{7: }e │{7: }e | 1733{1:~ }│{1:~ }│{1:~ }|*13 1734{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1735| 1736]] ) 1737 1738WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\ny\ny\ny\ne' ) 1739screen : expect ( [[ 1740{7: }a │{7: }a │{7: }^a | 1741{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1742{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1743{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1744{7: }e │{7: }e │{7: }e | 1745{1:~ }│{1:~ }│{1:~ }|*13 1746{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1747| 1748]] ) 1749 1750WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\ny\ny\ny\ny' ) 1751screen : expect ( [[ 1752{7: }a │{7: }a │{7: }^a | 1753{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1754{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1755{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1756{7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:y}{4: }| 1757{1:~ }│{1:~ }│{1:~ }|*13 1758{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1759| 1760]] ) 1761 1762WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\nb\ny\nd\ne' ) 1763screen : expect ( [[ 1764{7: }a │{7: }a │{7: }^a | 1765{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 1766{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1767{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }| 1768{7: }e │{7: }e │{7: }e | 1769{1:~ }│{1:~ }│{1:~ }|*13 1770{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1771| 1772]] ) 1773 1774WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\nb\ny\ny\ne' ) 1775screen : expect ( [[ 1776{7: }a │{7: }a │{7: }^a | 1777{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 1778{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1779{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1780{7: }e │{7: }e │{7: }e | 1781{1:~ }│{1:~ }│{1:~ }|*13 1782{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1783| 1784]] ) 1785 1786WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\nb\ny\ny\ny' ) 1787screen : expect ( [[ 1788{7: }a │{7: }a │{7: }^a | 1789{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 1790{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }| 1791{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1792{7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:y}{4: }| 1793{1:~ }│{1:~ }│{1:~ }|*13 1794{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1795| 1796]] ) 1797 1798WriteDiffFiles3 ( 'a\nb' , 'x\nb' , 'y\ny' ) 1799write_file ( 'Xdiin1' , 'a\nb' ) 1800write_file ( 'Xdinew1' , 'x\nb' ) 1801write_file ( 'Xdiout1' , '1c1' ) 1802write_file ( 'Xdiin2' , 'a\nb' ) 1803write_file ( 'Xdinew2' , 'y\ny' ) 1804write_file ( 'Xdiout2' , '1c1\n2c2' ) 1805command ( 'set diffexpr=DiffExprStub()' ) 1806screen : expect ( [[ 1807{7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }| 1808{7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }| 1809{1:~ }│{1:~ }│{1:~ }|*16 1810{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1811| 1812]] ) 1813command ( 'set diffexpr&' ) 1814 1815WriteDiffFiles3 ( 'a\nb\nc\nd' , 'x\nb\nx\nd' , 'y\ny\nc\nd' ) 1816write_file ( 'Xdiin1' , 'a\nb\nc\nd' ) 1817write_file ( 'Xdinew1' , 'x\nb\nx\nd' ) 1818write_file ( 'Xdiout1' , '1c1\n3c3' ) 1819write_file ( 'Xdiin2' , 'a\nb\nc\nd' ) 1820write_file ( 'Xdinew2' , 'y\ny\nc\nd' ) 1821write_file ( 'Xdiout2' , '1c1\n2c2' ) 1822command ( 'set diffexpr=DiffExprStub()' ) 1823screen : expect ( [[ 1824{7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }| 1825{7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }| 1826{7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:c}{4: }| 1827{7: }d │{7: }d │{7: }d | 1828{1:~ }│{1:~ }│{1:~ }|*14 1829{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1830| 1831]] ) 1832command ( 'set diffexpr&' ) 1833 1834WriteDiffFiles3 ( 'a\nb\nc\nd' , 'x\nb\nx\nd' , 'y\ny\ny\nd' ) 1835write_file ( 'Xdiin1' , 'a\nb\nc\nd' ) 1836write_file ( 'Xdinew1' , 'x\nb\nx\nd' ) 1837write_file ( 'Xdiout1' , '1c1\n3c3' ) 1838write_file ( 'Xdiin2' , 'a\nb\nc\nd' ) 1839write_file ( 'Xdinew2' , 'y\ny\ny\nd' ) 1840write_file ( 'Xdiout2' , '1c1\n2,3c2,3' ) 1841command ( 'set diffexpr=DiffExprStub()' ) 1842screen : expect ( [[ 1843{7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }| 1844{7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }| 1845{7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1846{7: }d │{7: }d │{7: }d | 1847{1:~ }│{1:~ }│{1:~ }|*14 1848{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1849| 1850]] ) 1851command ( 'set diffexpr&' ) 1852 1853WriteDiffFiles3 ( 'a\nb\nc\nd' , 'x\nb\nx\nd' , 'y\ny\ny\ny' ) 1854write_file ( 'Xdiin1' , 'a\nb\nc\nd' ) 1855write_file ( 'Xdinew1' , 'x\nb\nx\nd' ) 1856write_file ( 'Xdiout1' , '1c1\n3c3' ) 1857write_file ( 'Xdiin2' , 'a\nb\nc\nd' ) 1858write_file ( 'Xdinew2' , 'y\ny\ny\ny' ) 1859write_file ( 'Xdiout2' , '1c1\n2,4c2,4' ) 1860command ( 'set diffexpr=DiffExprStub()' ) 1861screen : expect ( [[ 1862{7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }| 1863{7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }| 1864{7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 1865{7: }{27:d}{4: }│{7: }{27:d}{4: }│{7: }{27:y}{4: }| 1866{1:~ }│{1:~ }│{1:~ }|*14 1867{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1868| 1869]] ) 1870command ( 'set diffexpr&' ) 1871 1872WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'b\nc' ) 1873screen : expect ( [[ 1874{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^b}{4: }| 1875{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1876{7: }c │{7: }c │{7: }c | 1877{1:~ }│{1:~ }│{1:~ }|*15 1878{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1879| 1880]] ) 1881 1882WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'c' ) 1883screen : expect ( [[ 1884{7: }{4:a }│{7: }{4:a }│{7: }{23:---------}| 1885{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1886{7: }c │{7: }c │{7: }^c | 1887{1:~ }│{1:~ }│{1:~ }|*15 1888{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1889| 1890]] ) 1891 1892WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , '' ) 1893screen : expect ( [[ 1894{7: }{4:a }│{7: }{4:a }│{7: }{23:---------}| 1895{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1896{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1897{1:~ }│{1:~ }│{7: }^ | 1898{1:~ }│{1:~ }│{1:~ }|*14 1899{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1900| 1901]] ) 1902 1903WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'a\nc' ) 1904screen : expect ( [[ 1905{7: }a │{7: }a │{7: }^a | 1906{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1907{7: }c │{7: }c │{7: }c | 1908{1:~ }│{1:~ }│{1:~ }|*15 1909{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1910| 1911]] ) 1912 1913WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'a' ) 1914screen : expect ( [[ 1915{7: }a │{7: }a │{7: }^a | 1916{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1917{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1918{1:~ }│{1:~ }│{1:~ }|*15 1919{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1920| 1921]] ) 1922 1923WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'b' ) 1924screen : expect ( [[ 1925{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^b}{4: }| 1926{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1927{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1928{1:~ }│{1:~ }│{1:~ }|*15 1929{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1930| 1931]] ) 1932 1933WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'd\ne' ) 1934screen : expect ( [[ 1935{7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^d}{4: }| 1936{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1937{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1938{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1939{7: }e │{7: }e │{7: }e | 1940{1:~ }│{1:~ }│{1:~ }|*13 1941{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1942| 1943]] ) 1944 1945WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'e' ) 1946screen : expect ( [[ 1947{7: }{4:a }│{7: }{4:a }│{7: }{23:---------}| 1948{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1949{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1950{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1951{7: }e │{7: }e │{7: }^e | 1952{1:~ }│{1:~ }│{1:~ }|*13 1953{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1954| 1955]] ) 1956 1957WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\nd\ne' ) 1958screen : expect ( [[ 1959{7: }a │{7: }a │{7: }^a | 1960{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }| 1961{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1962{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1963{7: }e │{7: }e │{7: }e | 1964{1:~ }│{1:~ }│{1:~ }|*13 1965{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1966| 1967]] ) 1968 1969WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\ne' ) 1970screen : expect ( [[ 1971{7: }a │{7: }a │{7: }^a | 1972{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1973{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1974{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1975{7: }e │{7: }e │{7: }e | 1976{1:~ }│{1:~ }│{1:~ }|*13 1977{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1978| 1979]] ) 1980 1981WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a' ) 1982screen : expect ( [[ 1983{7: }a │{7: }a │{7: }^a | 1984{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1985{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 1986{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1987{7: }{4:e }│{7: }{4:e }│{7: }{23:---------}| 1988{1:~ }│{1:~ }│{1:~ }|*13 1989{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 1990| 1991]] ) 1992 1993WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\nb\nd\ne' ) 1994screen : expect ( [[ 1995{7: }a │{7: }a │{7: }^a | 1996{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 1997{7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:d}{4: }| 1998{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 1999{7: }e │{7: }e │{7: }e | 2000{1:~ }│{1:~ }│{1:~ }|*13 2001{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2002| 2003]] ) 2004 2005WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\nb\ne' ) 2006screen : expect ( [[ 2007{7: }a │{7: }a │{7: }^a | 2008{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 2009{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 2010{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 2011{7: }e │{7: }e │{7: }e | 2012{1:~ }│{1:~ }│{1:~ }|*13 2013{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2014| 2015]] ) 2016 2017WriteDiffFiles3 ( 'a\nb\nc\nd\ne' , 'a\nx\nc\nx\ne' , 'a\nb' ) 2018screen : expect ( [[ 2019{7: }a │{7: }a │{7: }^a | 2020{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 2021{7: }{4:c }│{7: }{4:c }│{7: }{23:---------}| 2022{7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}| 2023{7: }{4:e }│{7: }{4:e }│{7: }{23:---------}| 2024{1:~ }│{1:~ }│{1:~ }|*13 2025{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2026| 2027]] ) 2028 2029WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'a\ny\nb\nc' ) 2030screen : expect ( [[ 2031{7: }a │{7: }a │{7: }^a | 2032{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }| 2033{7: }{23:---------}│{7: }{23:---------}│{7: }{22:b }| 2034{7: }c │{7: }c │{7: }c | 2035{1:~ }│{1:~ }│{1:~ }|*14 2036{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2037| 2038]] ) 2039 2040WriteDiffFiles3 ( 'a\nb\nc' , 'a\nx\nc' , 'a\nb\ny\nc' ) 2041screen : expect ( [[ 2042{7: }a │{7: }a │{7: }^a | 2043{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 2044{7: }{23:---------}│{7: }{23:---------}│{7: }{22:y }| 2045{7: }c │{7: }c │{7: }c | 2046{1:~ }│{1:~ }│{1:~ }|*14 2047{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2048| 2049]] ) 2050 2051WriteDiffFiles3 ( 'a\nb\nc' , 'd\ne' , 'b\nf' ) 2052screen : expect ( [[ 2053{7: }{27:a}{4: }│{7: }{27:d}{4: }│{7: }{27:^b}{4: }| 2054{7: }{27:b}{4: }│{7: }{27:e}{4: }│{7: }{27:f}{4: }| 2055{7: }{22:c }│{7: }{23:---------}│{7: }{23:---------}| 2056{1:~ }│{1:~ }│{1:~ }|*15 2057{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2058| 2059]] ) 2060 2061WriteDiffFiles3 ( 'a\nb\nc' , 'd\ne' , 'b' ) 2062screen : expect ( [[ 2063{7: }{27:a}{4: }│{7: }{27:d}{4: }│{7: }{27:^b}{4: }| 2064{7: }{27:b}{4: }│{7: }{27:e}{4: }│{7: }{23:---------}| 2065{7: }{22:c }│{7: }{23:---------}│{7: }{23:---------}| 2066{1:~ }│{1:~ }│{1:~ }|*15 2067{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2068| 2069]] ) 2070 2071-- File 3 overlaps twice, 2nd overlap completely within the existing block. 2072WriteDiffFiles3 ( 'foo\na\nb\nc\nbar' , 'foo\nw\nx\ny\nz\nbar' , 'foo\n1\na\nb\n2\nbar' ) 2073screen : expect ( [[ 2074{7: }foo │{7: }foo │{7: }^foo | 2075{7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }| 2076{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:a}{4: }| 2077{7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:b}{4: }| 2078{7: }{23:---------}│{7: }{27:z}{4: }│{7: }{27:2}{4: }| 2079{7: }bar │{7: }bar │{7: }bar | 2080{1:~ }│{1:~ }│{1:~ }|*12 2081{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2082| 2083]] ) 2084 2085-- File 3 overlaps twice, 2nd overlap extends beyond existing block on new 2086-- side. Make sure we don't over-extend the range and hit 'bar'. 2087WriteDiffFiles3 ( 'foo\na\nb\nc\nd\nbar' , 'foo\nw\nx\ny\nz\nu\nbar' , 'foo\n1\na\nb\n2\nd\nbar' ) 2088screen : expect ( [[ 2089{7: }foo │{7: }foo │{7: }^foo | 2090{7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }| 2091{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:a}{4: }| 2092{7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:b}{4: }| 2093{7: }{27:d}{4: }│{7: }{27:z}{4: }│{7: }{27:2}{4: }| 2094{7: }{23:---------}│{7: }{27:u}{4: }│{7: }{27:d}{4: }| 2095{7: }bar │{7: }bar │{7: }bar | 2096{1:~ }│{1:~ }│{1:~ }|*11 2097{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2098| 2099]] ) 2100 2101-- Chained overlaps. File 3's 2nd overlap spans two diff blocks and is longer 2102-- than the 2nd one. 2103WriteDiffFiles3 ( 2104'foo\na\nb\nc\nd\ne\nf\nbar' , 2105'foo\nw\nx\ny\nz\ne\nu\nbar' , 2106'foo\n1\nb\n2\n3\nd\n4\nf\nbar' 2107) 2108screen : expect ( [[ 2109{7: }foo │{7: }foo │{7: }^foo | 2110{7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }| 2111{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }| 2112{7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:2}{4: }| 2113{7: }{27:d}{4: }│{7: }{27:z}{4: }│{7: }{27:3}{4: }| 2114{7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:d}{4: }| 2115{7: }{27:f}{4: }│{7: }{27:u}{4: }│{7: }{27:4}{4: }| 2116{7: }{23:---------}│{7: }{23:---------}│{7: }{22:f }| 2117{7: }bar │{7: }bar │{7: }bar | 2118{1:~ }│{1:~ }│{1:~ }|*9 2119{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2120| 2121]] ) 2122 2123-- File 3 has 2 overlaps. An add and a delete. First overlap's expansion hits 2124-- the 2nd one. Make sure we adjust the diff block to have fewer lines. 2125WriteDiffFiles3 ( 'foo\na\nb\nbar' , 'foo\nx\ny\nbar' , 'foo\n1\na\nbar' ) 2126screen : expect ( [[ 2127{7: }foo │{7: }foo │{7: }^foo | 2128{7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:1}{4: }| 2129{7: }{27:b}{4: }│{7: }{27:y}{4: }│{7: }{27:a}{4: }| 2130{7: }bar │{7: }bar │{7: }bar | 2131{1:~ }│{1:~ }│{1:~ }|*14 2132{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2133| 2134]] ) 2135 2136-- File 3 has 2 overlaps. An add and another add. First overlap's expansion hits 2137-- the 2nd one. Make sure we adjust the diff block to have more lines. 2138WriteDiffFiles3 ( 'foo\na\nb\nc\nd\nbar' , 'foo\nw\nx\ny\nz\nu\nbar' , 'foo\n1\na\nb\n3\n4\nd\nbar' ) 2139screen : expect ( [[ 2140{7: }foo │{7: }foo │{7: }^foo | 2141{7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }| 2142{7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:a}{4: }| 2143{7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:b}{4: }| 2144{7: }{27:d}{4: }│{7: }{27:z}{4: }│{7: }{27:3}{4: }| 2145{7: }{23:---------}│{7: }{27:u}{4: }│{7: }{27:4}{4: }| 2146{7: }{23:---------}│{7: }{23:---------}│{7: }{22:d }| 2147{7: }bar │{7: }bar │{7: }bar | 2148{1:~ }│{1:~ }│{1:~ }|*10 2149{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 2150| 2151]] ) 2152end ) 2153 2154-- oldtest: Test_diff_topline_noscroll() 2155it ( 'diff mode does not scroll with line("w0")' , function () 2156local screen =Screen . new ( 45 , 20 ) 2157exec ( [[ 2158set scrolloff=5 2159call setline(1, range(1,60)) 2160vnew 2161call setline(1, range(1,10) + range(50,60)) 2162windo diffthis 2163norm! G 2164exe "norm! 30\<C-y>" 2165]] ) 2166screen : expect ( [[ 2167{7: }9 │{7: }9 | 2168{7: }10 │{7: }10 | 2169{7: }{23:--------------------}│{7: }{22:11 }| 2170{7: }{23:--------------------}│{7: }{22:12 }| 2171{7: }{23:--------------------}│{7: }{22:13 }| 2172{7: }{23:--------------------}│{7: }{22:14 }| 2173{7: }{23:--------------------}│{7: }{22:15 }| 2174{7: }{23:--------------------}│{7: }{22:16 }| 2175{7: }{23:--------------------}│{7: }{22:17 }| 2176{7: }{23:--------------------}│{7: }{22:18 }| 2177{7: }{23:--------------------}│{7: }{22:19 }| 2178{7: }{23:--------------------}│{7: }{22:20 }| 2179{7: }{23:--------------------}│{7: }{22:^21 }| 2180{7: }{23:--------------------}│{7: }{22:22 }| 2181{7: }{23:--------------------}│{7: }{22:23 }| 2182{7: }{23:--------------------}│{7: }{22:24 }| 2183{7: }{23:--------------------}│{7: }{22:25 }| 2184{7: }{23:--------------------}│{7: }{22:26 }| 2185{2:[No Name] [+] }{3:[No Name] [+] }| 2186| 2187]] ) 2188command ( [[echo line('w0', 1001)]] ) 2189screen : expect ( [[ 2190{7: }9 │{7: }9 | 2191{7: }10 │{7: }10 | 2192{7: }{23:--------------------}│{7: }{22:11 }| 2193{7: }{23:--------------------}│{7: }{22:12 }| 2194{7: }{23:--------------------}│{7: }{22:13 }| 2195{7: }{23:--------------------}│{7: }{22:14 }| 2196{7: }{23:--------------------}│{7: }{22:15 }| 2197{7: }{23:--------------------}│{7: }{22:16 }| 2198{7: }{23:--------------------}│{7: }{22:17 }| 2199{7: }{23:--------------------}│{7: }{22:18 }| 2200{7: }{23:--------------------}│{7: }{22:19 }| 2201{7: }{23:--------------------}│{7: }{22:20 }| 2202{7: }{23:--------------------}│{7: }{22:^21 }| 2203{7: }{23:--------------------}│{7: }{22:22 }| 2204{7: }{23:--------------------}│{7: }{22:23 }| 2205{7: }{23:--------------------}│{7: }{22:24 }| 2206{7: }{23:--------------------}│{7: }{22:25 }| 2207{7: }{23:--------------------}│{7: }{22:26 }| 2208{2:[No Name] [+] }{3:[No Name] [+] }| 22099 | 2210]] ) 2211feed ( '<C-W>p' ) 2212screen : expect ( [[ 2213{7: }{23:--------------------}│{7: }{22:39 }| 2214{7: }{23:--------------------}│{7: }{22:40 }| 2215{7: }{23:--------------------}│{7: }{22:41 }| 2216{7: }{23:--------------------}│{7: }{22:42 }| 2217{7: }{23:--------------------}│{7: }{22:43 }| 2218{7: }{23:--------------------}│{7: }{22:44 }| 2219{7: }{23:--------------------}│{7: }{22:45 }| 2220{7: }{23:--------------------}│{7: }{22:46 }| 2221{7: }{23:--------------------}│{7: }{22:47 }| 2222{7: }{23:--------------------}│{7: }{22:48 }| 2223{7: }{23:--------------------}│{7: }{22:49 }| 2224{7: }^50 │{7: }50 | 2225{7: }51 │{7: }51 | 2226{7: }52 │{7: }52 | 2227{7: }53 │{7: }53 | 2228{7: }54 │{7: }54 | 2229{7: }55 │{7: }55 | 2230{7:+ }{13:+-- 5 lines: 56····}│{7:+ }{13:+-- 5 lines: 56····}| 2231{3:[No Name] [+] }{2:[No Name] [+] }| 22329 | 2233]] ) 2234feed ( '<C-W>p' ) 2235screen : expect ( [[ 2236{7: }{23:--------------------}│{7: }{22:39 }| 2237{7: }{23:--------------------}│{7: }{22:40 }| 2238{7: }{23:--------------------}│{7: }{22:41 }| 2239{7: }{23:--------------------}│{7: }{22:42 }| 2240{7: }{23:--------------------}│{7: }{22:43 }| 2241{7: }{23:--------------------}│{7: }{22:^44 }| 2242{7: }{23:--------------------}│{7: }{22:45 }| 2243{7: }{23:--------------------}│{7: }{22:46 }| 2244{7: }{23:--------------------}│{7: }{22:47 }| 2245{7: }{23:--------------------}│{7: }{22:48 }| 2246{7: }{23:--------------------}│{7: }{22:49 }| 2247{7: }50 │{7: }50 | 2248{7: }51 │{7: }51 | 2249{7: }52 │{7: }52 | 2250{7: }53 │{7: }53 | 2251{7: }54 │{7: }54 | 2252{7: }55 │{7: }55 | 2253{7:+ }{13:+-- 5 lines: 56····}│{7:+ }{13:+-- 5 lines: 56····}| 2254{2:[No Name] [+] }{3:[No Name] [+] }| 22559 | 2256]] ) 2257end ) 2258 2259-- oldtest: Test_diff_inline() 2260it ( 'diff mode inline highlighting' , function () 2261write_file ( 'Xdifile1' , '' ) 2262write_file ( 'Xdifile2' , '' ) 2263finally ( function () 2264os . remove ( 'Xdifile1' ) 2265os . remove ( 'Xdifile2' ) 2266end ) 2267 2268local screen =Screen . new ( 37 , 20 ) 2269screen : add_extra_attr_ids ( { 2270[ 100 ] ={ background =Screen . colors . Blue1 } , 2271[ 101 ] ={ bold =true , background =Screen . colors . Red , foreground =Screen . colors . Blue1 } , 2272[ 102 ] ={ background =Screen . colors . LightMagenta , foreground =Screen . colors . Blue1 } , 2273[ 103 ] ={ bold =true , background =Screen . colors . Blue1 , foreground =Screen . colors . Blue1 } , 2274[ 104 ] ={ bold =true , background =Screen . colors . LightBlue , foreground =Screen . colors . Blue1 } , 2275} ) 2276command ( 'set winwidth=10' ) 2277command ( 'args Xdifile1 Xdifile2 | vert all | windo diffthis | 1wincmd w' ) 2278 2279WriteDiffFiles ( 'abcdef ghi jk n\nx\ny' , 'aBcef gHi lm n\ny\nz' ) 2280command ( 'set diffopt=internal,filler' ) 2281local s1 =[[ 2282{7: }{4:^a}{27:bcdef ghi jk}{4: n }│{7: }{4:a}{27:Bcef gHi lm}{4: n }| 2283{7: }{22:x }│{7: }{23:----------------}| 2284{7: }y │{7: }y | 2285{7: }{23:----------------}│{7: }{22:z }| 2286{1:~ }│{1:~ }|*14 2287{3:Xdifile1 }{2:Xdifile2 }| 2288| 2289]] 2290screen : expect ( s1 ) 2291command ( 'set diffopt=internal,filler diffopt+=inline:none' ) 2292local s2 =[[ 2293{7: }{4:^abcdef ghi jk n }│{7: }{4:aBcef gHi lm n }| 2294{7: }{22:x }│{7: }{23:----------------}| 2295{7: }y │{7: }y | 2296{7: }{23:----------------}│{7: }{22:z }| 2297{1:~ }│{1:~ }|*14 2298{3:Xdifile1 }{2:Xdifile2 }| 2299| 2300]] 2301screen : expect ( s2 ) 2302 2303-- inline:simple is the same as default 2304command ( 'set diffopt=internal,filler diffopt+=inline:simple' ) 2305screen : expect ( s1 ) 2306 2307command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2308local s3 =[[ 2309{7: }{4:^a}{27:b}{4:c}{27:d}{4:ef g}{27:h}{4:i }{27:jk}{4: n }│{7: }{4:a}{27:B}{4:cef g}{27:H}{4:i }{27:lm}{4: n }| 2310{7: }{22:x }│{7: }{23:----------------}| 2311{7: }y │{7: }y | 2312{7: }{23:----------------}│{7: }{22:z }| 2313{1:~ }│{1:~ }|*14 2314{3:Xdifile1 }{2:Xdifile2 }| 2315| 2316]] 2317screen : expect ( s3 ) 2318 2319command ( 'set diffopt=internal,filler diffopt+=inline:word' ) 2320screen : expect ( [[ 2321{7: }{27:^abcdef ghi jk}{4: n }│{7: }{27:aBcef gHi lm}{4: n }| 2322{7: }{22:x }│{7: }{23:----------------}| 2323{7: }y │{7: }y | 2324{7: }{23:----------------}│{7: }{22:z }| 2325{1:~ }│{1:~ }|*14 2326{3:Xdifile1 }{2:Xdifile2 }| 2327| 2328]] ) 2329 2330-- multiple inline values will the last one 2331command ( 'set diffopt=internal,filler diffopt+=inline:none,inline:char,inline:simple' ) 2332screen : expect ( s1 ) 2333command ( 'set diffopt=internal,filler diffopt+=inline:simple,inline:word,inline:none' ) 2334screen : expect ( s2 ) 2335command ( 'set diffopt=internal,filler diffopt+=inline:simple,inline:word,inline:char' ) 2336screen : expect ( s3 ) 2337 2338-- DiffTextAdd highlight 2339command ( 'hi DiffTextAdd guibg=blue' ) 2340command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2341screen : expect ( [[ 2342{7: }{4:^a}{27:b}{4:c}{100:d}{4:ef g}{27:h}{4:i }{27:jk}{4: n }│{7: }{4:a}{27:B}{4:cef g}{27:H}{4:i }{27:lm}{4: n }| 2343{7: }{22:x }│{7: }{23:----------------}| 2344{7: }y │{7: }y | 2345{7: }{23:----------------}│{7: }{22:z }| 2346{1:~ }│{1:~ }|*14 2347{3:Xdifile1 }{2:Xdifile2 }| 2348| 2349]] ) 2350 2351-- Live update in insert mode 2352feed ( 'isometext' ) 2353screen : expect ( [[ 2354{7: }{27:sometext^abcd}{4:ef g}│{7: }{27:aBc}{4:ef g}{27:H}{4:i }{27:lm}{4: n }| 2355{7: }{22:x }│{7: }{23:----------------}| 2356{7: }y │{7: }y | 2357{7: }{23:----------------}│{7: }{22:z }| 2358{1:~ }│{1:~ }|*14 2359{3:Xdifile1 [+] }{2:Xdifile2 }| 2360{5:-- INSERT --} | 2361]] ) 2362feed ( '<Esc>' ) 2363command ( 'silent! undo' ) 2364 2365-- icase simple scenarios 2366command ( 'set diffopt=internal,filler diffopt+=inline:simple,icase' ) 2367screen : expect ( [[ 2368{7: }{4:^abc}{27:def ghi jk}{4: n }│{7: }{4:aBc}{27:ef gHi lm}{4: n }| 2369{7: }{22:x }│{7: }{23:----------------}| 2370{7: }y │{7: }y | 2371{7: }{23:----------------}│{7: }{22:z }| 2372{1:~ }│{1:~ }|*14 2373{3:Xdifile1 }{2:Xdifile2 }| 2374| 2375]] ) 2376command ( 'set diffopt=internal,filler diffopt+=inline:char,icase' ) 2377screen : expect ( [[ 2378{7: }{4:^abc}{100:d}{4:ef ghi }{27:jk}{4: n }│{7: }{4:aBcef gHi }{27:lm}{4: n }| 2379{7: }{22:x }│{7: }{23:----------------}| 2380{7: }y │{7: }y | 2381{7: }{23:----------------}│{7: }{22:z }| 2382{1:~ }│{1:~ }|*14 2383{3:Xdifile1 }{2:Xdifile2 }| 2384| 2385]] ) 2386command ( 'set diffopt=internal,filler diffopt+=inline:word,icase' ) 2387screen : expect ( [[ 2388{7: }{27:^abcdef}{4: ghi }{27:jk}{4: n }│{7: }{27:aBcef}{4: gHi }{27:lm}{4: n }| 2389{7: }{22:x }│{7: }{23:----------------}| 2390{7: }y │{7: }y | 2391{7: }{23:----------------}│{7: }{22:z }| 2392{1:~ }│{1:~ }|*14 2393{3:Xdifile1 }{2:Xdifile2 }| 2394| 2395]] ) 2396 2397screen : try_resize ( 45 , 20 ) 2398command ( 'wincmd =' ) 2399-- diff algorithms should affect highlight 2400WriteDiffFiles ( 'apples and oranges' , 'oranges and apples' ) 2401command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2402screen : expect ( [[ 2403{7: }{27:^appl}{4:es and }{27:orang}{4:es }│{7: }{27:orang}{4:es and }{27:appl}{4:es }| 2404{1:~ }│{1:~ }|*17 2405{3:Xdifile1 }{2:Xdifile2 }| 2406| 2407]] ) 2408command ( 'set diffopt=internal,filler diffopt+=inline:char,algorithm:patience' ) 2409screen : expect ( [[ 2410{7: }{100:^apples and }{4:oranges }│{7: }{4:oranges}{100: and apples}{4: }| 2411{1:~ }│{1:~ }|*17 2412{3:Xdifile1 }{2:Xdifile2 }| 2413| 2414]] ) 2415 2416screen : try_resize ( 65 , 20 ) 2417command ( 'wincmd =' ) 2418-- icase: composing chars and Unicode fold case edge cases 2419WriteDiffFiles ( 2420'1 - sigma in 6σ and Ὀδυσσεύς\n1 - angstrom in åå\n1 - composing: ii⃗I⃗' , 2421'2 - Sigma in 6Σ and ὈΔΥΣΣΕΎΣ\n2 - Angstrom in ÅÅ\n2 - Composing: i⃗I⃗I⃗' 2422) 2423command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2424screen : expect ( [[ 2425{7: }{27:^1}{4: - }{27:s}{4:igma in 6}{27:σ}{4: and Ὀ}{27:δυσσεύς}{4: }│{7: }{27:2}{4: - }{27:S}{4:igma in 6}{27:Σ}{4: and Ὀ}{27:ΔΥΣΣΕΎΣ}{4: }| 2426{7: }{27:1}{4: - }{27:a}{4:ngstrom in }{27:åå}{4: }│{7: }{27:2}{4: - }{27:A}{4:ngstrom in }{27:ÅÅ}{4: }| 2427{7: }{27:1}{4: - }{27:c}{4:omposing: }{100:i}{4:i⃗I⃗ }│{7: }{27:2}{4: - }{27:C}{4:omposing: i⃗I⃗}{100:I⃗}{4: }| 2428{1:~ }│{1:~ }|*15 2429{3:Xdifile1 }{2:Xdifile2 }| 2430| 2431]] ) 2432command ( 'set diffopt=internal,filler diffopt+=inline:char,icase' ) 2433screen : expect ( [[ 2434{7: }{27:^1}{4: - sigma in 6σ and Ὀδυσσεύς }│{7: }{27:2}{4: - Sigma in 6Σ and ὈΔΥΣΣΕΎΣ }| 2435{7: }{27:1}{4: - angstrom in åå }│{7: }{27:2}{4: - Angstrom in ÅÅ }| 2436{7: }{27:1}{4: - composing: }{27:i}{4:i⃗I⃗ }│{7: }{27:2}{4: - Composing: }{27:i⃗}{4:I⃗I⃗ }| 2437{1:~ }│{1:~ }|*15 2438{3:Xdifile1 }{2:Xdifile2 }| 2439| 2440]] ) 2441 2442screen : try_resize ( 35 , 20 ) 2443command ( 'wincmd =' ) 2444-- wide chars 2445WriteDiffFiles ( 'abc😅xde一\nf🚀g' , 'abcy😢de\n二f🚀g' ) 2446command ( 'set diffopt=internal,filler diffopt+=inline:char,icase' ) 2447screen : expect ( [[ 2448{7: }{4:^abc}{27:😅x}{4:de}{100:一}{4: }│{7: }{4:abc}{27:y😢}{4:de }| 2449{7: }{4:f🚀g }│{7: }{100:二}{4:f🚀g }| 2450{1:~ }│{1:~ }|*16 2451{3:Xdifile1 }{2:Xdifile2 }| 2452| 2453]] ) 2454 2455-- NUL char 2456WriteDiffFiles ( '1\00034\0005\0006' , '1234\0005\n6' ) 2457command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2458screen : expect ( [[ 2459{7: }{4:^1}{101:^@}{4:34}{102:^@}{4:5}{101:^@}{4:6 }│{7: }{4:1}{27:2}{4:34}{102:^@}{4:5 }| 2460{7: }{23:---------------}│{7: }{4:6 }| 2461{1:~ }│{1:~ }|*16 2462{3:Xdifile1 }{2:Xdifile2 }| 2463| 2464]] ) 2465 2466-- word diff: always use first buffer's iskeyword and ignore others' for consistency 2467WriteDiffFiles ( 'foo+bar test' , 'foo+baz test' ) 2468command ( 'set diffopt=internal,filler diffopt+=inline:word' ) 2469local sw1 =[[ 2470{7: }{4:^foo+}{27:bar}{4: test }│{7: }{4:foo+}{27:baz}{4: test }| 2471{1:~ }│{1:~ }|*17 2472{3:Xdifile1 }{2:Xdifile2 }| 2473| 2474]] 2475screen : expect ( sw1 ) 2476 2477command ( 'set iskeyword+=+ | diffupdate' ) 2478screen : expect ( [[ 2479{7: }{27:^foo+bar}{4: test }│{7: }{27:foo+baz}{4: test }| 2480{1:~ }│{1:~ }|*17 2481{3:Xdifile1 }{2:Xdifile2 }| 2482| 2483]] ) 2484 2485command ( 'set iskeyword& | wincmd w' ) 2486command ( 'set iskeyword+=+ | wincmd w | diffupdate' ) 2487-- Use the previous screen as 2nd buffer's iskeyword does not matter 2488screen : expect ( sw1 ) 2489 2490command ( 'windo set iskeyword& | 1wincmd w' ) 2491 2492screen : try_resize ( 75 , 20 ) 2493command ( 'wincmd =' ) 2494-- word diff: test handling of multi-byte characters. Only alphanumeric chars 2495-- (e.g. Greek alphabet, but not CJK/emoji) count as words. 2496WriteDiffFiles ( 2497'🚀⛵️一二三ひらがなΔέλτα Δelta foobar' , 2498'🚀🛸一二四ひらなδέλτα δelta foobar' 2499) 2500command ( 'set diffopt=internal,filler diffopt+=inline:word' ) 2501screen : expect ( [[ 2502{7: }{4:^🚀}{27:⛵️}{4:一二}{27:三}{4:ひら}{27:がなΔέλτα Δelta}{4: fooba}│{7: }{4:🚀}{27:🛸}{4:一二}{27:四}{4:ひら}{27:なδέλτα δelta}{4: foobar }| 2503{1:~ }│{1:~ }|*17 2504{3:Xdifile1 }{2:Xdifile2 }| 2505| 2506]] ) 2507 2508screen : try_resize ( 69 , 20 ) 2509command ( 'wincmd =' ) 2510-- char diff: should slide highlight to whitespace boundary if possible for 2511-- better readability (by using forced indent-heuristics). A wrong result 2512-- would be if the highlight is "Bar, prefix". It should be "prefixBar, " 2513-- instead. 2514WriteDiffFiles ( 'prefixFoo, prefixEnd' , 'prefixFoo, prefixBar, prefixEnd' ) 2515command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2516screen : expect ( [[ 2517{7: }{4:^prefixFoo, prefixEnd }│{7: }{4:prefixFoo, }{100:prefixBar, }{4:prefixEnd }| 2518{1:~ }│{1:~ }|*17 2519{3:Xdifile1 }{2:Xdifile2 }| 2520| 2521]] ) 2522 2523screen : try_resize ( 39 , 20 ) 2524command ( 'wincmd =' ) 2525-- char diff: small gaps between inline diff blocks will be merged during refine step 2526-- - first segment: test that we iteratively merge small gaps after we merged 2527-- adjacent blocks, but only with limited number (set to 4) of iterations. 2528-- - second and third segments: show that we need a large enough adjacent block to 2529-- trigger a merge. 2530-- - fourth segment: small gaps are not merged when adjacent large block is 2531-- on a different line. 2532WriteDiffFiles ( 2533'abcdefghijklmno\nanchor1\n' 2534.. 'abcdefghijklmno\nanchor2\n' 2535.. 'abcdefghijklmno\nanchor3\n' 2536.. 'test\nmultiline' , 2537'a?c?e?g?i?k???o\nanchor1\n' 2538.. 'a??de?????klmno\nanchor2\n' 2539.. 'a??de??????lmno\nanchor3\n' 2540.. 't?s?\n??????i?e' 2541) 2542command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2543screen : expect ( [[ 2544{7: }{4:^a}{27:b}{4:c}{27:defghijklmn}{4:o }│{7: }{4:a}{27:?}{4:c}{27:?e?g?i?k???}{4:o }| 2545{7: }anchor1 │{7: }anchor1 | 2546{7: }{4:a}{27:bc}{4:de}{27:fghij}{4:klmno }│{7: }{4:a}{27:??}{4:de}{27:?????}{4:klmno }| 2547{7: }anchor2 │{7: }anchor2 | 2548{7: }{4:a}{27:bcdefghijk}{4:lmno }│{7: }{4:a}{27:??de??????}{4:lmno }| 2549{7: }anchor3 │{7: }anchor3 | 2550{7: }{4:t}{27:e}{4:s}{27:t}{4: }│{7: }{4:t}{27:?}{4:s}{27:?}{4: }| 2551{7: }{27:multilin}{4:e }│{7: }{27:??????i?}{4:e }| 2552{1:~ }│{1:~ }|*10 2553{3:Xdifile1 }{2:Xdifile2 }| 2554| 2555]] ) 2556 2557screen : try_resize ( 49 , 20 ) 2558command ( 'wincmd =' ) 2559-- Test multi-line blocks and whitespace 2560WriteDiffFiles ( 2561'this is \nsometest text foo\nbaz abc def \none\nword another word\nadditional line' , 2562'this is some test\ntexts\nfoo bar abX Yef \noneword another word' 2563) 2564command ( 'set diffopt=internal,filler diffopt+=inline:char,iwhite' ) 2565screen : expect ( [[ 2566{7: }{4:^this is }│{7: }{4:this is some}{100: }{4:test }| 2567{7: }{4:sometest text foo }│{7: }{4:text}{100:s}{4: }| 2568{7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }| 2569{7: }{4:one }│{7: }{4:oneword another word }| 2570{7: }{4:word another word }│{7: }{23:----------------------}| 2571{7: }{22:additional line }│{7: }{23:----------------------}| 2572{1:~ }│{1:~ }|*12 2573{3:Xdifile1 }{2:Xdifile2 }| 2574| 2575]] ) 2576command ( 'set diffopt=internal,filler diffopt+=inline:word,iwhite' ) 2577screen : expect ( [[ 2578{7: }{4:^this is }│{7: }{4:this is }{27:some test}{4: }| 2579{7: }{27:sometest text foo}{4: }│{7: }{27:texts}{4: }| 2580{7: }{27:baz abc def}{4: }│{7: }{27:foo bar abX}{4: }{27:Yef}{4: }| 2581{7: }{27:one}{4: }│{7: }{27:oneword}{4: another word }| 2582{7: }{27:word}{4: another word }│{7: }{23:----------------------}| 2583{7: }{22:additional line }│{7: }{23:----------------------}| 2584{1:~ }│{1:~ }|*12 2585{3:Xdifile1 }{2:Xdifile2 }| 2586| 2587]] ) 2588command ( 'set diffopt=internal,filler diffopt+=inline:char,iwhiteeol' ) 2589screen : expect ( [[ 2590{7: }{4:^this }{100: }{4:is }│{7: }{4:this is some}{100: }{4:test }| 2591{7: }{4:sometest text foo }│{7: }{4:text}{100:s}{4: }| 2592{7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }| 2593{7: }{4:one }│{7: }{4:oneword another word }| 2594{7: }{4:word another word }│{7: }{23:----------------------}| 2595{7: }{22:additional line }│{7: }{23:----------------------}| 2596{1:~ }│{1:~ }|*12 2597{3:Xdifile1 }{2:Xdifile2 }| 2598| 2599]] ) 2600command ( 'set diffopt=internal,filler diffopt+=inline:word,iwhiteeol' ) 2601screen : expect ( [[ 2602{7: }{4:^this }{100: }{4:is }│{7: }{4:this is }{27:some test}{4: }| 2603{7: }{27:sometest text}{4: foo }│{7: }{27:texts}{4: }| 2604{7: }{27:baz abc def}{4: }│{7: }{4:foo }{27:bar abX Yef}{4: }| 2605{7: }{27:one}{4: }│{7: }{27:oneword}{4: another word }| 2606{7: }{27:word}{4: another word }│{7: }{23:----------------------}| 2607{7: }{22:additional line }│{7: }{23:----------------------}| 2608{1:~ }│{1:~ }|*12 2609{3:Xdifile1 }{2:Xdifile2 }| 2610| 2611]] ) 2612command ( 'set diffopt=internal,filler diffopt+=inline:char,iwhiteall' ) 2613screen : expect ( [[ 2614{7: }{4:^this is }│{7: }{4:this is some test }| 2615{7: }{4:sometest text foo }│{7: }{4:text}{100:s}{4: }| 2616{7: }{4:ba}{27:z}{4: ab}{27:c d}{4:ef }│{7: }{4:foo ba}{27:r}{4: ab}{27:X Y}{4:ef }| 2617{7: }{4:one }│{7: }{4:oneword another word }| 2618{7: }{4:word another word }│{7: }{23:----------------------}| 2619{7: }{22:additional line }│{7: }{23:----------------------}| 2620{1:~ }│{1:~ }|*12 2621{3:Xdifile1 }{2:Xdifile2 }| 2622| 2623]] ) 2624command ( 'set diffopt=internal,filler diffopt+=inline:word,iwhiteall' ) 2625screen : expect ( [[ 2626{7: }{4:^this is }│{7: }{4:this is }{27:some test}{4: }| 2627{7: }{27:sometest text}{4: foo }│{7: }{27:texts}{4: }| 2628{7: }{27:baz abc def }{4: }│{7: }{4:foo }{27:bar abX Yef }{4: }| 2629{7: }{27:one}{4: }│{7: }{27:oneword}{4: another word }| 2630{7: }{27:word}{4: another word }│{7: }{23:----------------------}| 2631{7: }{22:additional line }│{7: }{23:----------------------}| 2632{1:~ }│{1:~ }|*12 2633{3:Xdifile1 }{2:Xdifile2 }| 2634| 2635]] ) 2636 2637-- newline should be highlighted too when 'list' is set 2638command ( 'windo set list listchars=eol:$' ) 2639command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2640screen : expect ( [[ 2641{7: }{4:this }{100: }{4:is }{100: }{103:$}{4: }│{7: }{4:^this is some}{100: }{4:test}{101:$}{4: }| 2642{7: }{4:sometest}{27: }{4:text}{27: }{4:foo}{101:$}{4: }│{7: }{4:text}{27:s}{101:$}{4: }| 2643{7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }{11:$}{4: }│{7: }{4:foo}{27: }{4:ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }{100: }{11:$}{4: }| 2644{7: }{4:one}{103:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }| 2645{7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}| 2646{7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}| 2647{1:~ }│{1:~ }|*12 2648{2:Xdifile1 }{3:Xdifile2 }| 2649| 2650]] ) 2651command ( 'set diffopt=internal,filler diffopt+=inline:char,iwhite' ) 2652screen : expect ( [[ 2653{7: }{4:this is }{11:$}{4: }│{7: }{4:^this is some}{100: }{4:test}{11:$}{4: }| 2654{7: }{4:sometest text foo}{11:$}{4: }│{7: }{4:text}{100:s}{11:$}{4: }| 2655{7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }{11:$}{4: }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }{11:$}{4: }| 2656{7: }{4:one}{103:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }| 2657{7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}| 2658{7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}| 2659{1:~ }│{1:~ }|*12 2660{2:Xdifile1 }{3:Xdifile2 }| 2661| 2662]] ) 2663command ( 'set diffopt=internal,filler diffopt+=inline:char,iwhiteeol' ) 2664screen : expect ( [[ 2665{7: }{4:this }{100: }{4:is }{11:$}{4: }│{7: }{4:^this is some}{100: }{4:test}{11:$}{4: }| 2666{7: }{4:sometest text foo}{11:$}{4: }│{7: }{4:text}{100:s}{11:$}{4: }| 2667{7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }{11:$}{4: }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }{11:$}{4: }| 2668{7: }{4:one}{103:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }| 2669{7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}| 2670{7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}| 2671{1:~ }│{1:~ }|*12 2672{2:Xdifile1 }{3:Xdifile2 }| 2673| 2674]] ) 2675command ( 'set diffopt=internal,filler diffopt+=inline:char,iwhiteall' ) 2676screen : expect ( [[ 2677{7: }{4:this is }{11:$}{4: }│{7: }{4:^this is some test}{11:$}{4: }| 2678{7: }{4:sometest text foo}{11:$}{4: }│{7: }{4:text}{100:s}{11:$}{4: }| 2679{7: }{4:ba}{27:z}{4: ab}{27:c d}{4:ef }{11:$}{4: }│{7: }{4:foo ba}{27:r}{4: ab}{27:X Y}{4:ef }{11:$}{4: }| 2680{7: }{4:one}{11:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }| 2681{7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}| 2682{7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}| 2683{1:~ }│{1:~ }|*12 2684{2:Xdifile1 }{3:Xdifile2 }| 2685| 2686]] ) 2687command ( 'windo set nolist' ) 2688end ) 2689 2690-- oldtest: Test_diff_inline_multibuffer() 2691it ( 'diff mode inline highlighting with 3 buffers' , function () 2692write_file ( 'Xdifile1' , '' ) 2693write_file ( 'Xdifile2' , '' ) 2694write_file ( 'Xdifile3' , '' ) 2695finally ( function () 2696os . remove ( 'Xdifile1' ) 2697os . remove ( 'Xdifile2' ) 2698os . remove ( 'Xdifile3' ) 2699end ) 2700 2701local screen =Screen . new ( 75 , 20 ) 2702screen : add_extra_attr_ids ( { 2703[ 100 ] ={ background =Screen . colors . Blue1 } , 2704} ) 2705command ( 'args Xdifile1 Xdifile2 Xdifile3 | vert all | windo diffthis | 1wincmd w' ) 2706command ( 'wincmd =' ) 2707command ( 'hi DiffTextAdd guibg=Blue' ) 2708 2709WriteDiffFiles3 ( 2710'That is buffer1.\nanchor\nSome random text\nanchor' , 2711'This is buffer2.\nanchor\nSome text\nanchor\nbuffer2/3' , 2712'This is buffer3. Last.\nanchor\nSome more\ntext here.\nanchor\nonly in buffer2/3\nnot in buffer1' 2713) 2714command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2715local s1 =[[ 2716{7: }{4:^Th}{27:at}{4: is buffer}{27:1}{4:. }│{7: }{4:Th}{27:is}{4: is buffer}{27:2}{4:. }│{7: }{4:Th}{27:is}{4: is buffer}{27:3. Last}{4:.}| 2717{7: }anchor │{7: }anchor │{7: }anchor | 2718{7: }{4:Some }{27:random }{4:text }│{7: }{4:Some text }│{7: }{4:Some }{27:more}{4: }| 2719{7: }{23:-----------------------}│{7: }{23:----------------------}│{7: }{4:text}{100: here.}{4: }| 2720{7: }anchor │{7: }anchor │{7: }anchor | 2721{7: }{23:-----------------------}│{7: }{4:buffer2/3 }│{7: }{100:only in }{4:buffer2/3 }| 2722{7: }{23:-----------------------}│{7: }{23:----------------------}│{7: }{22:not in buffer1 }| 2723{1:~ }│{1:~ }│{1:~ }|*11 2724{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2725| 2726]] 2727screen : expect ( s1 ) 2728 2729-- Close one of the buffers and make sure it updates correctly 2730command ( 'diffoff' ) 2731screen : expect ( [[ 2732^That is buffer1. │{7: }{4:This is buffer}{27:2}{4:. }│{7: }{4:This is buffer}{27:3. Last}{4:.}| 2733anchor │{7: }anchor │{7: }anchor | 2734Some random text │{7: }{4:Some text }│{7: }{4:Some }{100:more}{4: }| 2735anchor │{7: }{23:----------------------}│{7: }{4:text}{100: here.}{4: }| 2736{1:~ }│{7: }anchor │{7: }anchor | 2737{1:~ }│{7: }{4:buffer2/3 }│{7: }{100:only in }{4:buffer2/3 }| 2738{1:~ }│{7: }{23:----------------------}│{7: }{22:not in buffer1 }| 2739{1:~ }│{1:~ }│{1:~ }|*11 2740{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2741| 2742]] ) 2743 2744-- Update text in the non-diff buffer and nothing should be changed 2745feed ( 'isometext' ) 2746screen : expect ( [[ 2747sometext^That is buffer1. │{7: }{4:This is buffer}{27:2}{4:. }│{7: }{4:This is buffer}{27:3. Last}{4:.}| 2748anchor │{7: }anchor │{7: }anchor | 2749Some random text │{7: }{4:Some text }│{7: }{4:Some }{100:more}{4: }| 2750anchor │{7: }{23:----------------------}│{7: }{4:text}{100: here.}{4: }| 2751{1:~ }│{7: }anchor │{7: }anchor | 2752{1:~ }│{7: }{4:buffer2/3 }│{7: }{100:only in }{4:buffer2/3 }| 2753{1:~ }│{7: }{23:----------------------}│{7: }{22:not in buffer1 }| 2754{1:~ }│{1:~ }│{1:~ }|*11 2755{3:Xdifile1 [+] }{2:Xdifile2 Xdifile3 }| 2756{5:-- INSERT --} | 2757]] ) 2758feed ( '<Esc>' ) 2759command ( 'silent! undo' ) 2760 2761command ( 'diffthis' ) 2762screen : expect ( s1 ) 2763 2764-- Test that removing first buffer from diff will in turn use the next 2765-- earliest buffer's iskeyword during word diff. 2766WriteDiffFiles3 ( 'This+is=a-setence' , 'This+is=another-setence' , 'That+is=a-setence' ) 2767command ( 'set iskeyword+=+ | 2wincmd w | set iskeyword+=- | 1wincmd w' ) 2768command ( 'set diffopt=internal,filler diffopt+=inline:word' ) 2769local s4 =[[ 2770{7: }{27:^This+is=a}{4:-setence }│{7: }{27:This+is=another}{4:-setenc}│{7: }{27:That+is=a}{4:-setence }| 2771{1:~ }│{1:~ }│{1:~ }|*17 2772{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2773| 2774]] 2775screen : expect ( s4 ) 2776command ( 'diffoff' ) 2777screen : expect ( [[ 2778^This+is=a-setence │{7: }{27:This}{4:+is=}{27:another-setenc}│{7: }{27:That}{4:+is=}{27:a-setence}{4: }| 2779{1:~ }│{1:~ }│{1:~ }|*17 2780{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2781| 2782]] ) 2783command ( 'diffthis' ) 2784screen : expect ( s4 ) 2785 2786-- Test multi-buffer char diff refinement, and that removing a buffer from 2787-- diff will update the others properly. 2788WriteDiffFiles3 ( 'abcdefghijkYmYYY' , 'aXXdXXghijklmnop' , 'abcdefghijkYmYop' ) 2789command ( 'set diffopt=internal,filler diffopt+=inline:char' ) 2790local s6 =[[ 2791{7: }{4:^a}{27:bcdef}{4:ghijk}{27:YmYYY}{4: }│{7: }{4:a}{27:XXdXX}{4:ghijk}{27:lmnop}{4: }│{7: }{4:a}{27:bcdef}{4:ghijk}{27:YmYop}{4: }| 2792{1:~ }│{1:~ }│{1:~ }|*17 2793{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2794| 2795]] 2796screen : expect ( s6 ) 2797command ( 'diffoff' ) 2798screen : expect ( [[ 2799^abcdefghijkYmYYY │{7: }{4:a}{27:XXdXX}{4:ghijk}{27:l}{4:m}{27:n}{4:op }│{7: }{4:a}{27:bcdef}{4:ghijk}{27:Y}{4:m}{27:Y}{4:op }| 2800{1:~ }│{1:~ }│{1:~ }|*17 2801{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2802| 2803]] ) 2804command ( 'diffthis' ) 2805screen : expect ( s6 ) 2806end ) 2807 2808-- oldtest: Test_diff_inline_multibuffer_empty_block() 2809it ( 'diff mode inline highlighting with multi-buffer and empty block' , function () 2810write_file ( 'Xdifile1' , 'anchor1\n1234567890abcde\nanchor2' ) 2811write_file ( 'Xdifile2' , 'anchor1\n1234567--0abc-e\nanchor2' ) 2812write_file ( 'Xdifile3' , 'anchor1\nanchor2' ) 2813write_file ( 'Xdifile4' , 'anchor1\n1???????90abcd?\nanchor2' ) 2814finally ( function () 2815os . remove ( 'Xdifile1' ) 2816os . remove ( 'Xdifile2' ) 2817os . remove ( 'Xdifile3' ) 2818os . remove ( 'Xdifile4' ) 2819end ) 2820local screen =Screen . new ( 83 , 20 ) 2821command ( 'args Xdifile1 Xdifile2 Xdifile3 Xdifile4 | vert all | windo diffthis' ) 2822command ( '1wincmd w | set diffopt=filler,internal,inline:char' ) 2823screen : expect ( [[ 2824{7: }^anchor1 │{7: }anchor1 │{7: }anchor1 │{7: }anchor1 | 2825{7: }{4:1}{27:23456789}{4:0abc}{27:de}{4: }│{7: }{4:1}{27:234567--}{4:0abc}{27:-e}{4: }│{7: }{23:------------------}│{7: }{4:1}{27:???????9}{4:0abc}{27:d?}{4: }| 2826{7: }anchor2 │{7: }anchor2 │{7: }anchor2 │{7: }anchor2 | 2827{1:~ }│{1:~ }│{1:~ }│{1:~ }|*15 2828{3:Xdifile1 }{2:Xdifile2 Xdifile3 Xdifile4 }| 2829| 2830]] ) 2831n . assert_alive () 2832end ) 2833 2834it ( 'diff mode algorithm:histogram and inline:char with long lines #34329' , function () 2835local screen =Screen . new ( 55 , 20 ) 2836exec ( [[ 2837set diffopt=internal,filler,closeoff,algorithm:histogram,inline:char 2838cd test/functional/fixtures/diff/ 2839args inline_char_file1 inline_char_file2 2840vert all | windo diffthis | 1wincmd w 2841]] ) 2842screen : expect ( [[ 2843{7: }{27:^aaaa,aaaaaaaa,aaaaaaaaaa,}│{7: }{27:bbbb,bbbbbbbb,bbbbbbbbbb,}| 2844{7: }{27:aaaaaaa-aaaaaaaaa-aaaaaa-}│{7: }{27:bbbbbbb-bbbbbbbbb-bbbbbb-}|*11 2845{1:~ }│{1:~ }|*6 2846{3:inline_char_file1 }{2:inline_char_file2 }| 2847| 2848]] ) 2849n . assert_alive () 2850feed ( 'G$' ) 2851screen : expect ( [[ 2852{7: }{4: }│{7: }{4: }| 2853{7: }{27:aa,aa,aa,aa,aa,a,a}{4:" }│{7: }{27:,bb,bb,bb,bb,bb,b,b}{4:" }| 2854{7: }{27:,aa,aa,aa,aa,aa,a}{4:" }│{7: }{27:b,bb,bb,bb,bb,bb,bb,b}{4:" }| 2855{7: }{27:,aa,aa,aa,aa,aa}{4:" }│{7: }{27:bb,bb,bb,bb,bb,bb,bb,bb}{4:" }| 2856{7: }{27:a,aa,aa,aa,aa}{4:" }│{7: }{27:,bb,b,bb,bb,bb}{4:" }| 2857{7: }{27:aa,aa,aa,aa,aa}{4:" }│{7: }{27:,bb,bb}{4:" }| 2858{7: }{27:a,a,a}{4:" }│{7: }{27:b,b,b,b,b}{4:" }| 2859{7: }{27:a,a,a,a,a}{4:" }│{7: }{27:,b,b,b,b,b}{4:" }| 2860{7: }{27:aa,a,a,a,a,a,a}{4:" }│{7: }{27:b,b,b,b,b,b}{4:" }| 2861{7: }{27:,aa,aa,a,a,a,a,a}{4:" }│{7: }{27:bb,b,b,b,b,b}{4:" }| 2862{7: }{27:aa,aa,aa,aa,a,a,a,a}{4:" }│{7: }{27:bb,bb,bb,b,b,b,b}{4:" }| 2863{7: }{27:,aa,aa,a,a,a}{4:^" }│{7: }{27:bb,bb,bb,bb,b,b,b}{4:" }| 2864{1:~ }│{1:~ }|*6 2865{3:inline_char_file1 }{2:inline_char_file2 }| 2866| 2867]] ) 2868end ) 2869 2870-- oldtest: Test_linematch_diff() 2871it ( [["linematch" in 'diffopt' implies "filler"]] , function () 2872local screen =Screen . new ( 55 , 20 ) 2873command ( 'set diffopt=internal,filler,closeoff,inline:simple,linematch:30' ) 2874 2875write_file ( 'Xdifile1' , '' ) 2876write_file ( 'Xdifile2' , '' ) 2877finally ( function () 2878os . remove ( 'Xdifile1' ) 2879os . remove ( 'Xdifile2' ) 2880end ) 2881 2882WriteDiffFiles ( '// d?\n// d?' , '!\nabc d!\nd!' ) 2883command ( 'args Xdifile1 Xdifile2 | vert all | windo diffthis | 1wincmd w' ) 2884screen : expect ( [[ 2885{7: }{23:-------------------------}│{7: }{22:! }| 2886{7: }{27:^// d?}{4: }│{7: }{27:abc d!}{4: }| 2887{7: }{27:// d?}{4: }│{7: }{27:d!}{4: }| 2888{1:~ }│{1:~ }|*15 2889{3:Xdifile1 }{2:Xdifile2 }| 2890| 2891]] ) 2892 2893-- test that filler is always implicitly set by linematch 2894command ( 'set diffopt-=filler' ) 2895screen : expect_unchanged () 2896end ) 2897 2898describe ( "'diffanchors'" , function () 2899local screen 2900 2901before_each ( function () 2902screen =Screen . new ( 32 , 20 ) 2903command ( 'set winwidth=10 nohlsearch shortmess+=s' ) 2904end ) 2905 2906after_each ( function () 2907os . remove ( 'Xdifile1' ) 2908os . remove ( 'Xdifile2' ) 2909os . remove ( 'Xdifile3' ) 2910end ) 2911 2912it ( 'works' , function () 2913WriteDiffFiles3 ( 2914'anchorA1\n1\n2\n3\n100\n101\n102\nanchorB\n103\n104\n105' , 2915'100\n101\n102\nanchorB\n103\n104\n105\nanchorA2\n1\n2\n3' , 2916'100\nanchorB\n103\nanchorA3\n1\n2\n3' 2917) 2918command ( 'args Xdifile1 Xdifile2 Xdifile3 | vert all | windo diffthis | 1wincmd w' ) 2919 2920-- Simple diff without any anchors 2921command ( 'set diffopt=filler,internal' ) 2922local s0 =[[ 2923{7: }{22:^anchorA1}│{7: }{23:--------}│{7: }{23:--------}| 2924{7: }{22:1 }│{7: }{23:--------}│{7: }{23:--------}| 2925{7: }{22:2 }│{7: }{23:--------}│{7: }{23:--------}| 2926{7: }{22:3 }│{7: }{23:--------}│{7: }{23:--------}| 2927{7: }100 │{7: }100 │{7: }100 | 2928{7: }{22:101 }│{7: }{22:101 }│{7: }{23:--------}| 2929{7: }{22:102 }│{7: }{22:102 }│{7: }{23:--------}| 2930{7: }anchorB │{7: }anchorB │{7: }anchorB | 2931{7: }103 │{7: }103 │{7: }103 | 2932{7: }{27:104}{4: }│{7: }{27:104}{4: }│{7: }{27:anchorA3}| 2933{7: }{4:1}{27:05}{4: }│{7: }{4:1}{27:05}{4: }│{7: }{4:1 }| 2934{7: }{23:--------}│{7: }{27:anchorA}{4:2}│{7: }{4:2 }| 2935{7: }{23:--------}│{7: }{27:1}{4: }│{7: }{27:3}{4: }| 2936{7: }{23:--------}│{7: }{22:2 }│{7: }{23:--------}| 2937{7: }{23:--------}│{7: }{22:3 }│{7: }{23:--------}| 2938{1:~ }│{1:~ }│{1:~ }|*3 2939{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2940| 2941]] 2942screen : expect ( s0 ) 2943 2944-- Setting diffopt+=anchor or diffanchors without the other won't do anything 2945command ( 'set diffopt=filler,internal diffopt+=anchor' ) 2946screen : expect_unchanged () 2947command ( 'set diffopt=filler,internal dia=1/anchorA/' ) 2948screen : expect_unchanged () 2949 2950-- Use a single anchor by specifying a pattern. Test both internal and 2951-- external diff to make sure both paths work. 2952command ( 'set diffopt=filler dia=1/anchorA/ diffopt+=anchor' ) 2953local s1 =[[ 2954{7: }{23:--------}│{7: }{4:100 }│{7: }{4:100 }| 2955{7: }{23:--------}│{7: }{27:101}{4: }│{7: }{27:anchorB}{4: }| 2956{7: }{23:--------}│{7: }{4:10}{27:2}{4: }│{7: }{4:10}{27:3}{4: }| 2957{7: }{23:--------}│{7: }{22:anchorB }│{7: }{23:--------}| 2958{7: }{23:--------}│{7: }{22:103 }│{7: }{23:--------}| 2959{7: }{23:--------}│{7: }{22:104 }│{7: }{23:--------}| 2960{7: }{23:--------}│{7: }{22:105 }│{7: }{23:--------}| 2961{7: }{4:^anchorA}{27:1}│{7: }{4:anchorA}{27:2}│{7: }{4:anchorA}{27:3}| 2962{7: }1 │{7: }1 │{7: }1 | 2963{7: }2 │{7: }2 │{7: }2 | 2964{7: }3 │{7: }3 │{7: }3 | 2965{7: }{22:100 }│{7: }{23:--------}│{7: }{23:--------}| 2966{7: }{22:101 }│{7: }{23:--------}│{7: }{23:--------}| 2967{7: }{22:102 }│{7: }{23:--------}│{7: }{23:--------}| 2968{7: }{22:anchorB }│{7: }{23:--------}│{7: }{23:--------}| 2969{7: }{22:103 }│{7: }{23:--------}│{7: }{23:--------}| 2970{7: }{22:104 }│{7: }{23:--------}│{7: }{23:--------}| 2971{7: }{22:105 }│{7: }{23:--------}│{7: }{23:--------}| 2972{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2973| 2974]] 2975screen : expect ( s1 ) 2976command ( 'set diffopt+=internal' ) 2977screen : expect_unchanged () 2978 2979-- Use 2 anchors. They should be sorted by line number, so in file 2/3 2980-- anchorB is used before anchorA. 2981command ( 'set diffopt=filler dia=1/anchorA/,1/anchorB/ diffopt+=anchor' ) 2982local s2 =[[ 2983{7: }{23:--------}│{7: }{4:100 }│{7: }{4:100 }| 2984{7: }{23:--------}│{7: }{22:101 }│{7: }{23:--------}| 2985{7: }{23:--------}│{7: }{22:102 }│{7: }{23:--------}| 2986{7: }{4:^anchor}{27:A1}│{7: }{4:anchor}{27:B}{4: }│{7: }{4:anchor}{27:B}{4: }| 2987{7: }{4:1 }│{7: }{4:1}{27:03}{4: }│{7: }{4:1}{27:03}{4: }| 2988{7: }{27:2}{4: }│{7: }{27:104}{4: }│{7: }{23:--------}| 2989{7: }{27:3}{4: }│{7: }{27:105}{4: }│{7: }{23:--------}| 2990{7: }{22:100 }│{7: }{23:--------}│{7: }{23:--------}| 2991{7: }{22:101 }│{7: }{23:--------}│{7: }{23:--------}| 2992{7: }{22:102 }│{7: }{23:--------}│{7: }{23:--------}| 2993{7: }{4:anchor}{27:B}{4: }│{7: }{4:anchor}{27:A2}│{7: }{4:anchor}{27:A3}| 2994{7: }{4:1}{27:03}{4: }│{7: }{4:1 }│{7: }{4:1 }| 2995{7: }{27:104}{4: }│{7: }{27:2}{4: }│{7: }{27:2}{4: }| 2996{7: }{27:105}{4: }│{7: }{27:3}{4: }│{7: }{27:3}{4: }| 2997{1:~ }│{1:~ }│{1:~ }|*4 2998{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 2999| 3000]] 3001screen : expect ( s2 ) 3002command ( 'set diffopt+=internal' ) 3003screen : expect_unchanged () 3004 3005-- Set marks and specify addresses using marks and repeat the test 3006command ( '2wincmd w | 1/anchorA/mark a' ) 3007command ( '1/anchorB/mark b' ) 3008command ( '3wincmd w | 1/anchorA/mark a' ) 3009command ( '1/anchorB/mark b' ) 3010command ( '1wincmd w | 1/anchorA/mark a' ) 3011command ( '1/anchorB/mark b' ) 3012 3013command ( "set diffopt=filler,internal dia='a diffopt+=anchor" ) 3014screen : expect ( s1 ) 3015command ( "set diffopt=filler,internal dia='a,'b diffopt+=anchor" ) 3016screen : expect ( s2 ) 3017 3018-- Update marks to point somewhere else. When we first set the mark the diff 3019-- won't be updated until we manually invoke :diffupdate. 3020command ( "set diffopt=filler,internal dia='a diffopt+=anchor" ) 3021screen : expect ( s1 ) 3022command ( '1wincmd w | 1/anchorB/mark a' ) 3023screen : expect_unchanged () 3024command ( 'diffupdate' ) 3025screen : expect ( [[ 3026{7: }{22:^anchorA1}│{7: }{23:--------}│{7: }{23:--------}| 3027{7: }{22:1 }│{7: }{23:--------}│{7: }{23:--------}| 3028{7: }{22:2 }│{7: }{23:--------}│{7: }{23:--------}| 3029{7: }{22:3 }│{7: }{23:--------}│{7: }{23:--------}| 3030{7: }100 │{7: }100 │{7: }100 | 3031{7: }{27:101}{4: }│{7: }{27:101}{4: }│{7: }{27:anchorB}{4: }| 3032{7: }{4:10}{27:2}{4: }│{7: }{4:10}{27:2}{4: }│{7: }{4:10}{27:3}{4: }| 3033{7: }{23:--------}│{7: }{22:anchorB }│{7: }{23:--------}| 3034{7: }{23:--------}│{7: }{22:103 }│{7: }{23:--------}| 3035{7: }{23:--------}│{7: }{22:104 }│{7: }{23:--------}| 3036{7: }{23:--------}│{7: }{22:105 }│{7: }{23:--------}| 3037{7: }{4:anchor}{27:B}{4: }│{7: }{4:anchor}{27:A2}│{7: }{4:anchor}{27:A3}| 3038{7: }{4:1}{27:03}{4: }│{7: }{4:1 }│{7: }{4:1 }| 3039{7: }{27:104}{4: }│{7: }{27:2}{4: }│{7: }{27:2}{4: }| 3040{7: }{27:105}{4: }│{7: }{27:3}{4: }│{7: }{27:3}{4: }| 3041{1:~ }│{1:~ }│{1:~ }|*3 3042{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3043| 3044]] ) 3045 3046-- Use local diff anchors with line numbers, and repeat the same test 3047command ( '2wincmd w | setlocal dia=8' ) 3048command ( '3wincmd w | setlocal dia=4' ) 3049command ( '1wincmd w | setlocal dia=1' ) 3050command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3051screen : expect ( s1 ) 3052command ( '2wincmd w | setlocal dia=8,4' ) 3053command ( '3wincmd w | setlocal dia=4,2' ) 3054command ( '1wincmd w | setlocal dia=1,8' ) 3055command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3056screen : expect ( s2 ) 3057 3058-- Test multiple diff anchors on the same line in file 1. 3059command ( '1wincmd w | setlocal dia=1,1' ) 3060command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3061screen : expect ( [[ 3062{7: }{23:--------}│{7: }{4:100 }│{7: }{4:100 }| 3063{7: }{23:--------}│{7: }{22:101 }│{7: }{23:--------}| 3064{7: }{23:--------}│{7: }{22:102 }│{7: }{23:--------}| 3065{7: }{23:--------}│{7: }{4:anchorB }│{7: }{4:anchorB }| 3066{7: }{23:--------}│{7: }{4:103 }│{7: }{4:103 }| 3067{7: }{23:--------}│{7: }{22:104 }│{7: }{23:--------}| 3068{7: }{23:--------}│{7: }{22:105 }│{7: }{23:--------}| 3069{7: }{4:^anchorA}{27:1}│{7: }{4:anchorA}{27:2}│{7: }{4:anchorA}{27:3}| 3070{7: }1 │{7: }1 │{7: }1 | 3071{7: }2 │{7: }2 │{7: }2 | 3072{7: }3 │{7: }3 │{7: }3 | 3073{7: }{22:100 }│{7: }{23:--------}│{7: }{23:--------}| 3074{7: }{22:101 }│{7: }{23:--------}│{7: }{23:--------}| 3075{7: }{22:102 }│{7: }{23:--------}│{7: }{23:--------}| 3076{7: }{22:anchorB }│{7: }{23:--------}│{7: }{23:--------}| 3077{7: }{22:103 }│{7: }{23:--------}│{7: }{23:--------}| 3078{7: }{22:104 }│{7: }{23:--------}│{7: }{23:--------}| 3079{7: }{22:105 }│{7: }{23:--------}│{7: }{23:--------}| 3080{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3081| 3082]] ) 3083 3084-- Test that if one file has fewer diff anchors than others. Vim should only 3085-- use the minimum in this case. 3086command ( '1wincmd w | setlocal dia=8' ) 3087command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3088screen : expect ( [[ 3089{7: }{22:^anchorA1}│{7: }{23:--------}│{7: }{23:--------}| 3090{7: }{22:1 }│{7: }{23:--------}│{7: }{23:--------}| 3091{7: }{22:2 }│{7: }{23:--------}│{7: }{23:--------}| 3092{7: }{22:3 }│{7: }{23:--------}│{7: }{23:--------}| 3093{7: }100 │{7: }100 │{7: }100 | 3094{7: }{22:101 }│{7: }{22:101 }│{7: }{23:--------}| 3095{7: }{22:102 }│{7: }{22:102 }│{7: }{23:--------}| 3096{7: }anchorB │{7: }anchorB │{7: }anchorB | 3097{7: }103 │{7: }103 │{7: }103 | 3098{7: }{27:104}{4: }│{7: }{27:104}{4: }│{7: }{27:anchorA3}| 3099{7: }{4:1}{27:05}{4: }│{7: }{4:1}{27:05}{4: }│{7: }{4:1 }| 3100{7: }{23:--------}│{7: }{27:anchorA}{4:2}│{7: }{4:2 }| 3101{7: }{23:--------}│{7: }{27:1}{4: }│{7: }{27:3}{4: }| 3102{7: }{23:--------}│{7: }{22:2 }│{7: }{23:--------}| 3103{7: }{23:--------}│{7: }{22:3 }│{7: }{23:--------}| 3104{1:~ }│{1:~ }│{1:~ }|*3 3105{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3106| 3107]] ) 3108 3109-- $+1 should anchor everything past the last line 3110command ( '1wincmd w | setlocal dia=$+1' ) 3111command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3112screen : expect ( [[ 3113{7: }{22:^anchorA1}│{7: }{23:--------}│{7: }{23:--------}| 3114{7: }{22:1 }│{7: }{23:--------}│{7: }{23:--------}| 3115{7: }{22:2 }│{7: }{23:--------}│{7: }{23:--------}| 3116{7: }{22:3 }│{7: }{23:--------}│{7: }{23:--------}| 3117{7: }100 │{7: }100 │{7: }100 | 3118{7: }{4:101 }│{7: }{4:101 }│{7: }{23:--------}| 3119{7: }{4:102 }│{7: }{4:102 }│{7: }{23:--------}| 3120{7: }{22:anchorB }│{7: }{23:--------}│{7: }{23:--------}| 3121{7: }{22:103 }│{7: }{23:--------}│{7: }{23:--------}| 3122{7: }{22:104 }│{7: }{23:--------}│{7: }{23:--------}| 3123{7: }{22:105 }│{7: }{23:--------}│{7: }{23:--------}| 3124{7: }{23:--------}│{7: }{4:anchorB }│{7: }{4:anchorB }| 3125{7: }{23:--------}│{7: }{4:103 }│{7: }{4:103 }| 3126{7: }{23:--------}│{7: }{27:104}{4: }│{7: }{27:anchorA3}| 3127{7: }{23:--------}│{7: }{4:1}{27:05}{4: }│{7: }{4:1 }| 3128{7: }{23:--------}│{7: }{27:anchorA}{4:2}│{7: }{4:2 }| 3129{7: }{23:--------}│{7: }{27:1}{4: }│{7: }{27:3}{4: }| 3130{7: }{23:--------}│{7: }{22:2 }│{7: }{23:--------}| 3131{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3132| 3133]] ) 3134 3135-- Sorting of diff anchors should work with multiple anchors 3136command ( '1wincmd w | setlocal dia=1,10,8,2' ) 3137command ( '2wincmd w | setlocal dia=1,2,3,4' ) 3138command ( '3wincmd w | setlocal dia=4,3,2,1' ) 3139command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3140screen : expect ( [[ 3141{7: }{27:anchorA1}│{7: }{27:100}{4: }│{7: }{27:^100}{4: }| 3142{7: }{27:1}{4: }│{7: }{27:101}{4: }│{7: }{27:anchorB}{4: }| 3143{7: }{22:2 }│{7: }{23:--------}│{7: }{23:--------}| 3144{7: }{22:3 }│{7: }{23:--------}│{7: }{23:--------}| 3145{7: }{22:100 }│{7: }{23:--------}│{7: }{23:--------}| 3146{7: }{22:101 }│{7: }{23:--------}│{7: }{23:--------}| 3147{7: }{22:102 }│{7: }{23:--------}│{7: }{23:--------}| 3148{7: }{27:anchorB}{4: }│{7: }{27:102}{4: }│{7: }{27:103}{4: }| 3149{7: }{22:103 }│{7: }{23:--------}│{7: }{23:--------}| 3150{7: }{27:104}{4: }│{7: }{27:anchorB}{4: }│{7: }{27:anchorA3}| 3151{7: }{4:1}{27:05}{4: }│{7: }{4:1}{27:03}{4: }│{7: }{4:1 }| 3152{7: }{23:--------}│{7: }{27:104}{4: }│{7: }{27:2}{4: }| 3153{7: }{23:--------}│{7: }{27:105}{4: }│{7: }{27:3}{4: }| 3154{7: }{23:--------}│{7: }{22:anchorA2}│{7: }{23:--------}| 3155{7: }{23:--------}│{7: }{22:1 }│{7: }{23:--------}| 3156{7: }{23:--------}│{7: }{22:2 }│{7: }{23:--------}| 3157{7: }{23:--------}│{7: }{22:3 }│{7: }{23:--------}| 3158{1:~ }│{1:~ }│{1:~ }| 3159{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 3160| 3161]] ) 3162 3163-- Intentionally set an invalid anchor with wrong line number. Should fall 3164-- back to treat it as if no anchors are used at all. 3165command ( '1wincmd w | setlocal dia=1,10,8,2,1000 | silent! diffupdate' ) 3166screen : expect ( s0 ) 3167end ) 3168 3169-- oldtest: Test_diffanchors_scrollbind_topline() 3170it ( 'scrollbind works with adjacent diff blocks' , function () 3171WriteDiffFiles ( 'anchor1\ndiff1a\nanchor2' , 'anchor1\ndiff2a\nanchor2' ) 3172command ( 'args Xdifile1 Xdifile2 | vert all | windo diffthis | 1wincmd w' ) 3173 3174command ( '1wincmd w | setlocal dia=2' ) 3175command ( '2wincmd w | setlocal dia=3' ) 3176 3177command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3178screen : expect ( [[ 3179{7: }anchor1 │{7: }^anchor1 | 3180{7: }{23:-------------}│{7: }{22:diff2a }| 3181{7: }{22:diff1a }│{7: }{23:--------------}| 3182{7: }anchor2 │{7: }anchor2 | 3183{1:~ }│{1:~ }|*14 3184{2:Xdifile1 }{3:Xdifile2 }| 3185| 3186]] ) 3187feed ( '<C-E>' ) 3188screen : expect ( [[ 3189{7: }{23:-------------}│{7: }{22:^diff2a }| 3190{7: }{22:diff1a }│{7: }{23:--------------}| 3191{7: }anchor2 │{7: }anchor2 | 3192{1:~ }│{1:~ }|*15 3193{2:Xdifile1 }{3:Xdifile2 }| 3194| 3195]] ) 3196feed ( '<C-E>' ) 3197screen : expect ( [[ 3198{7: }{22:diff1a }│{7: }{23:--------------}| 3199{7: }anchor2 │{7: }^anchor2 | 3200{1:~ }│{1:~ }|*16 3201{2:Xdifile1 }{3:Xdifile2 }| 3202| 3203]] ) 3204feed ( '<C-E>' ) 3205screen : expect ( [[ 3206{7: }anchor2 │{7: }^anchor2 | 3207{1:~ }│{1:~ }|*17 3208{2:Xdifile1 }{3:Xdifile2 }| 3209| 3210]] ) 3211 3212-- Also test no-filler 3213feed ( 'gg' ) 3214command ( 'set diffopt=filler,internal diffopt+=anchor diffopt-=filler' ) 3215screen : expect ( [[ 3216{7: }anchor1 │{7: }^anchor1 | 3217{7: }{22:diff1a }│{7: }{22:diff2a }| 3218{7: }anchor2 │{7: }anchor2 | 3219{1:~ }│{1:~ }|*15 3220{2:Xdifile1 }{3:Xdifile2 }| 3221| 3222]] ) 3223feed ( '<C-E>' ) 3224screen : expect ( [[ 3225{7: }{22:diff1a }│{7: }{22:^diff2a }| 3226{7: }anchor2 │{7: }anchor2 | 3227{1:~ }│{1:~ }|*16 3228{2:Xdifile1 }{3:Xdifile2 }| 3229| 3230]] ) 3231feed ( '<C-E>' ) 3232screen : expect ( [[ 3233{7: }anchor2 │{7: }^anchor2 | 3234{1:~ }│{1:~ }|*17 3235{2:Xdifile1 }{3:Xdifile2 }| 3236| 3237]] ) 3238end ) 3239 3240-- oldtest: Test_diffanchors_scrollbind_topline2() 3241it ( 'scrollbind works with 3 files and overlapping diff blocks' , function () 3242WriteDiffFiles3 ( 3243'anchor1' , 3244'diff2a\ndiff2b\ndiff2c\ndiff2d\nanchor2' , 3245'diff3a\ndiff3c\ndiff3d\nanchor3\ndiff3e' 3246) 3247command ( 'args Xdifile1 Xdifile2 Xdifile3 | vert all | windo diffthis | 1wincmd w' ) 3248 3249command ( '1wincmd w | setlocal dia=1,1,2' ) 3250command ( '2wincmd w | setlocal dia=3,5,6' ) 3251command ( '3wincmd w | setlocal dia=2,4,5' ) 3252 3253command ( 'set diffopt=filler,internal diffopt+=anchor' ) 3254screen : expect ( [[ 3255{7: }{23:--------}│{7: }{4:diff}{27:2}{4:a }│{7: }{4:^diff}{27:3}{4:a }| 3256{7: }{23:--------}│{7: }{22:diff2b }│{7: }{23:--------}| 3257{7: }{23:--------}│{7: }{4:diff}{27:2}{4:c }│{7: }{4:diff}{27:3}{4:c }| 3258{7: }{23:--------}│{7: }{4:diff}{27:2}{4:d }│{7: }{4:diff}{27:3}{4:d }| 3259{7: }{4:anchor}{27:1}{4: }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:anchor}{27:3}{4: }| 3260{7: }{23:--------}│{7: }{23:--------}│{7: }{22:diff3e }| 3261{1:~ }│{1:~ }│{1:~ }|*12 3262{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 3263| 3264]] ) 3265command ( '1wincmd w' ) 3266feed ( '<C-E>' ) 3267screen : expect ( [[ 3268{7: }{23:--------}│{7: }{22:diff2b }│{7: }{23:--------}| 3269{7: }{23:--------}│{7: }{4:diff}{27:2}{4:c }│{7: }{4:diff}{27:3}{4:c }| 3270{7: }{23:--------}│{7: }{4:diff}{27:2}{4:d }│{7: }{4:diff}{27:3}{4:d }| 3271{7: }{4:^anchor}{27:1}{4: }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:anchor}{27:3}{4: }| 3272{7: }{23:--------}│{7: }{23:--------}│{7: }{22:diff3e }| 3273{1:~ }│{1:~ }│{1:~ }|*13 3274{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3275| 3276]] ) 3277feed ( '<C-E>' ) 3278screen : expect ( [[ 3279{7: }{23:--------}│{7: }{4:diff}{27:2}{4:c }│{7: }{4:diff}{27:3}{4:c }| 3280{7: }{23:--------}│{7: }{4:diff}{27:2}{4:d }│{7: }{4:diff}{27:3}{4:d }| 3281{7: }{4:^anchor}{27:1}{4: }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:anchor}{27:3}{4: }| 3282{7: }{23:--------}│{7: }{23:--------}│{7: }{22:diff3e }| 3283{1:~ }│{1:~ }│{1:~ }|*14 3284{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3285| 3286]] ) 3287feed ( '<C-E>' ) 3288screen : expect ( [[ 3289{7: }{23:--------}│{7: }{4:diff}{27:2}{4:d }│{7: }{4:diff}{27:3}{4:d }| 3290{7: }{4:^anchor}{27:1}{4: }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:anchor}{27:3}{4: }| 3291{7: }{23:--------}│{7: }{23:--------}│{7: }{22:diff3e }| 3292{1:~ }│{1:~ }│{1:~ }|*15 3293{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3294| 3295]] ) 3296feed ( '<C-E>' ) 3297screen : expect ( [[ 3298{7: }{4:^anchor}{27:1}{4: }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:anchor}{27:3}{4: }| 3299{7: }{23:--------}│{7: }{23:--------}│{7: }{22:diff3e }| 3300{1:~ }│{1:~ }│{1:~ }|*16 3301{3:Xdifile1 }{2:Xdifile2 Xdifile3 }| 3302| 3303]] ) 3304 3305-- Also test no-filler 3306command ( '3wincmd w' ) 3307feed ( 'gg' ) 3308command ( 'set diffopt=filler,internal diffopt+=anchor diffopt-=filler' ) 3309screen : expect ( [[ 3310{7: }{4:anchor}{27:1}{4: }│{7: }{4:diff}{27:2}{4:a }│{7: }{4:^diff}{27:3}{4:a }| 3311{1:~ }│{7: }{22:diff2b }│{7: }{4:diff}{27:3}{4:c }| 3312{1:~ }│{7: }{4:diff}{27:2}{4:c }│{7: }{4:diff}{27:3}{4:d }| 3313{1:~ }│{7: }{4:diff}{27:2}{4:d }│{7: }{4:anchor}{27:3}{4: }| 3314{1:~ }│{7: }{4:anchor}{27:2}{4: }│{7: }{22:diff3e }| 3315{1:~ }│{1:~ }│{1:~ }|*13 3316{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 3317| 3318]] ) 3319feed ( '<C-E>' ) 3320screen : expect ( [[ 3321{7: }{4:anchor}{27:1}{4: }│{7: }{4:diff}{27:2}{4:c }│{7: }{4:^diff}{27:3}{4:c }| 3322{1:~ }│{7: }{4:diff}{27:2}{4:d }│{7: }{4:diff}{27:3}{4:d }| 3323{1:~ }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:anchor}{27:3}{4: }| 3324{1:~ }│{1:~ }│{7: }{22:diff3e }| 3325{1:~ }│{1:~ }│{1:~ }|*14 3326{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 3327| 3328]] ) 3329feed ( '<C-E>' ) 3330screen : expect ( [[ 3331{7: }{4:anchor}{27:1}{4: }│{7: }{4:diff}{27:2}{4:d }│{7: }{4:^diff}{27:3}{4:d }| 3332{1:~ }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:anchor}{27:3}{4: }| 3333{1:~ }│{1:~ }│{7: }{22:diff3e }| 3334{1:~ }│{1:~ }│{1:~ }|*15 3335{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 3336| 3337]] ) 3338feed ( '<C-E>' ) 3339screen : expect ( [[ 3340{7: }{4:anchor}{27:1}{4: }│{7: }{4:anchor}{27:2}{4: }│{7: }{4:^anchor}{27:3}{4: }| 3341{1:~ }│{1:~ }│{7: }{22:diff3e }| 3342{1:~ }│{1:~ }│{1:~ }|*16 3343{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 3344| 3345]] ) 3346feed ( '<C-E>' ) 3347screen : expect ( [[ 3348{7: }{4:anchor}{27:1}{4: }│{7: }{4:anchor}{27:2}{4: }│{7: }{22:^diff3e }| 3349{1:~ }│{1:~ }│{1:~ }|*17 3350{2:Xdifile1 Xdifile2 }{3:Xdifile3 }| 3351| 3352]] ) 3353end ) 3354end ) 3355 3356-- oldtest: Test_diffexpr_wipe_buffers() 3357it ( ':%bwipe does not crash when using diffexpr' , function () 3358local screen =Screen . new ( 70 , 20 ) 3359exec ( [[ 3360func DiffFuncExpr() 3361let in = readblob(v:fname_in) 3362let new = readblob(v:fname_new) 3363let out = v:lua.vim.text.diff(in, new) 3364call writefile(split(out, "\n"), v:fname_out) 3365endfunc 3366 3367new 3368vnew 3369set diffexpr=DiffFuncExpr() 3370wincmd l 3371new 3372call setline(1,range(20)) 3373windo diffthis 3374wincmd w 3375hide 3376%bw! 3377]] ) 3378screen : expect ( [[ 3379^ | 3380{1:~ }|*18 33814 buffers wiped out | 3382]] ) 3383end ) 3384 3385-- oldtest: Test_diffput_to_empty_buf() 3386it ( ':diffput to empty buffer redraws properly' , function () 3387local screen =Screen . new ( 75 , 20 ) 3388exec ( [[ 3389set ruler 3390call setline(1, ['foo', 'bar', 'baz']) 3391rightbelow vnew 3392windo diffthis 3393windo set cursorline nofoldenable 3394wincmd t 3395]] ) 3396screen : add_extra_attr_ids ( { 3397[ 100 ] ={ underline =true , background =Screen . colors . LightBlue } , 3398} ) 3399screen : expect ( [[ 3400{7: }{100:^foo }│{7: }{23:-----------------------------------}| 3401{7: }{22:bar }│{7: }{23:-----------------------------------}| 3402{7: }{22:baz }│{7: }{23:-----------------------------------}| 3403{1:~ }│{7: }{21: }| 3404{1:~ }│{1:~ }|*14 3405{3:[No Name] [+] 1,1 All }{2:[No Name] 0,0-1 All}| 3406| 3407]] ) 3408feed ( '0' ) -- Trigger an initial 'cursorbind' check. 3409screen : expect_unchanged () 3410command ( 'diffput' ) 3411screen : expect ( [[ 3412{7: }{21:^foo }│{7: }foo | 3413{7: }bar │{7: }bar | 3414{7: }baz │{7: }{21:baz }| 3415{1:~ }│{1:~ }|*15 3416{3:[No Name] [+] 1,1 All }{2:[No Name] [+] 3,1 All}| 3417| 3418]] ) 3419command ( ':redraw!' ) 3420screen : expect_unchanged () 3421feed ( 'j' ) 3422screen : expect ( [[ 3423{7: }foo │{7: }foo | 3424{7: }{21:^bar }│{7: }{21:bar }| 3425{7: }baz │{7: }baz | 3426{1:~ }│{1:~ }|*15 3427{3:[No Name] [+] 2,1 All }{2:[No Name] [+] 2,1 All}| 3428| 3429]] ) 3430end )