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