12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670 |
- local helpers = require('test.functional.helpers')(after_each)
- local Screen = require('test.functional.ui.screen')
- local feed = helpers.feed
- local clear = helpers.clear
- local command = helpers.command
- local insert = helpers.insert
- local write_file = helpers.write_file
- local dedent = helpers.dedent
- local exec = helpers.exec
- local eq = helpers.eq
- local meths = helpers.meths
- before_each(clear)
- describe('Diff mode screen', function()
- local fname = 'Xtest-functional-diff-screen-1'
- local fname_2 = fname .. '.2'
- local screen
- local reread = function()
- feed(':e<cr><c-w>w:e<cr><c-w>w')
- end
- setup(function()
- os.remove(fname)
- os.remove(fname_2)
- end)
- teardown(function()
- os.remove(fname)
- os.remove(fname_2)
- end)
- before_each(function()
- feed(':e ' .. fname_2 .. '<cr>')
- feed(':vnew ' .. fname .. '<cr>')
- feed(':diffthis<cr>')
- feed('<c-w>w:diffthis<cr><c-w>w')
- screen = Screen.new(40, 16)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [3] = {reverse = true},
- [4] = {background = Screen.colors.LightBlue},
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {bold = true, reverse = true},
- [8] = {bold = true, background = Screen.colors.Red},
- [9] = {background = Screen.colors.LightMagenta},
- })
- end)
- it('Add a line in beginning of file 2', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1: }{2:------------------}│{1: }{4:0 }|
- {1: }^1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }{2:------------------}│{1: }{4:0 }|
- {1: }^1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line in beginning of file 1', function()
- write_file(fname, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(":set diffopt=filler<cr>")
- screen:expect([[
- {1: }{4:^0 }│{1: }{2:-----------------}|
- {1: }1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(":set diffopt+=internal<cr>")
- screen:expect([[
- {1: }{4:^0 }│{1: }{2:-----------------}|
- {1: }1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line at the end of file 2', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- reread()
- feed(":set diffopt=filler<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{2:------------------}│{1: }{4:11 }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(":set diffopt+=internal<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{2:------------------}│{1: }{4:11 }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- screen:try_resize(40, 9)
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- it('Add a line at the end of file 1', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(":set diffopt=filler<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{4:11 }│{1: }{2:-----------------}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(":set diffopt+=internal<cr>")
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{4:11 }│{1: }{2:-----------------}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- screen:try_resize(40, 9)
- screen:expect([[
- {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- it('Add a line in the middle of file 2, remove on at the end of file 1', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- write_file(fname_2, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1: }^1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }{2:------------------}│{1: }{4:4 }|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{4:11 }│{1: }{2:-----------------}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }^1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }{2:------------------}│{1: }{4:4 }|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{4:11 }│{1: }{2:-----------------}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Add a line in the middle of file 1, remove on at the end of file 2', function()
- write_file(fname, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1: }^1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }{4:4 }│{1: }{2:-----------------}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{2:------------------}│{1: }{4:11 }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }^1 │{1: }1 |
- {1: }2 │{1: }2 |
- {1: }3 │{1: }3 |
- {1: }4 │{1: }4 |
- {1: }{4:4 }│{1: }{2:-----------------}|
- {1: }5 │{1: }5 |
- {1: }6 │{1: }6 |
- {1: }7 │{1: }7 |
- {1: }8 │{1: }8 |
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }{2:------------------}│{1: }{4:11 }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- describe('normal/patience/histogram diff algorithm', function()
- setup(function()
- local f1 = [[#include <stdio.h>
- // Frobs foo heartily
- int frobnitz(int foo)
- {
- int i;
- for(i = 0; i < 10; i++)
- {
- printf("Your answer is: ");
- printf("%d\n", foo);
- }
- }
- int fact(int n)
- {
- if(n > 1)
- {
- return fact(n-1) * n;
- }
- return 1;
- }
- int main(int argc, char **argv)
- {
- frobnitz(fact(10));
- }]]
- write_file(fname, f1, false)
- local f2 = [[#include <stdio.h>
- int fib(int n)
- {
- if(n > 2)
- {
- return fib(n-1) + fib(n-2);
- }
- return 1;
- }
- // Frobs foo heartily
- int frobnitz(int foo)
- {
- int i;
- for(i = 0; i < 10; i++)
- {
- printf("%d\n", foo);
- }
- }
- int main(int argc, char **argv)
- {
- frobnitz(fib(10));
- }]]
- write_file(fname_2, f2, false)
- end)
- it('diffopt=+algorithm:myers', function()
- reread()
- feed(':set diffopt=internal,filler<cr>')
- screen:expect([[
- {1: }^#include <stdio.h>│{1: }#include <stdio.h|
- {1: } │{1: } |
- {1: }{8:// Frobs foo heart}│{1: }{8:int fib(int n)}{9: }|
- {1: }{4:int frobnitz(int f}│{1: }{2:-----------------}|
- {1: }{ │{1: }{ |
- {1: }{9: i}{8:nt i;}{9: }│{1: }{9: i}{8:f(n > 2)}{9: }|
- {1: }{4: for(i = 0; i <}│{1: }{2:-----------------}|
- {1: } { │{1: } { |
- {1: }{9: }{8:printf("Yo}│{1: }{9: }{8:return fi}|
- {1: }{4: printf("%d}│{1: }{2:-----------------}|
- {1: } } │{1: } } |
- {1: }{2:------------------}│{1: }{4: return 1; }|
- {1: }} │{1: }} |
- {1: } │{1: } |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler |
- ]])
- feed('G')
- screen:expect([[
- {1: }{2:------------------}│{1: }{4:int frobnitz(int }|
- {1: }{ │{1: }{ |
- {1: }{9: i}{8:f(n > 1)}{9: }│{1: }{9: i}{8:nt i;}{9: }|
- {1: }{2:------------------}│{1: }{4: for(i = 0; i }|
- {1: } { │{1: } { |
- {1: }{9: }{8:return fac}│{1: }{9: }{8:printf("%}|
- {1: } } │{1: } } |
- {1: }{4: return 1; }│{1: }{2:-----------------}|
- {1: }} │{1: }} |
- {1: } │{1: } |
- {1: }int main(int argc,│{1: }int main(int argc|
- {1: }{ │{1: }{ |
- {1: }{9: frobnitz(f}{8:act}{9:(}│{1: }{9: frobnitz(f}{8:ib}{9:(}|
- {1: }^} │{1: }} |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler |
- ]])
- end)
- it('diffopt+=algorithm:patience', function()
- reread()
- feed(':set diffopt=internal,filler,algorithm:patience<cr>')
- screen:expect([[
- {1: }^#include <stdio.h>│{1: }#include <stdio.h|
- {1: } │{1: } |
- {1: }{2:------------------}│{1: }{4:int fib(int n) }|
- {1: }{2:------------------}│{1: }{4:{ }|
- {1: }{2:------------------}│{1: }{4: if(n > 2) }|
- {1: }{2:------------------}│{1: }{4: { }|
- {1: }{2:------------------}│{1: }{4: return fi}|
- {1: }{2:------------------}│{1: }{4: } }|
- {1: }{2:------------------}│{1: }{4: return 1; }|
- {1: }{2:------------------}│{1: }{4:} }|
- {1: }{2:------------------}│{1: }{4: }|
- {1: }// Frobs foo heart│{1: }// Frobs foo hear|
- {1: }int frobnitz(int f│{1: }int frobnitz(int |
- {1: }{ │{1: }{ |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- feed('G')
- screen:expect([[
- {1: } │{1: } |
- {1: }{4:int fact(int n) }│{1: }{2:-----------------}|
- {1: }{4:{ }│{1: }{2:-----------------}|
- {1: }{4: if(n > 1) }│{1: }{2:-----------------}|
- {1: }{4: { }│{1: }{2:-----------------}|
- {1: }{4: return fac}│{1: }{2:-----------------}|
- {1: }{4: } }│{1: }{2:-----------------}|
- {1: }{4: return 1; }│{1: }{2:-----------------}|
- {1: }{4:} }│{1: }{2:-----------------}|
- {1: }{4: }│{1: }{2:-----------------}|
- {1: }int main(int argc,│{1: }int main(int argc|
- {1: }{ │{1: }{ |
- {1: }{9: frobnitz(f}{8:act}{9:(}│{1: }{9: frobnitz(f}{8:ib}{9:(}|
- {1: }^} │{1: }} |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- it('diffopt+=algorithm:histogram', function()
- reread()
- feed(':set diffopt=internal,filler,algorithm:histogram<cr>')
- screen:expect([[
- {1: }^#include <stdio.h>│{1: }#include <stdio.h|
- {1: } │{1: } |
- {1: }{2:------------------}│{1: }{4:int fib(int n) }|
- {1: }{2:------------------}│{1: }{4:{ }|
- {1: }{2:------------------}│{1: }{4: if(n > 2) }|
- {1: }{2:------------------}│{1: }{4: { }|
- {1: }{2:------------------}│{1: }{4: return fi}|
- {1: }{2:------------------}│{1: }{4: } }|
- {1: }{2:------------------}│{1: }{4: return 1; }|
- {1: }{2:------------------}│{1: }{4:} }|
- {1: }{2:------------------}│{1: }{4: }|
- {1: }// Frobs foo heart│{1: }// Frobs foo hear|
- {1: }int frobnitz(int f│{1: }int frobnitz(int |
- {1: }{ │{1: }{ |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- feed('G')
- screen:expect([[
- {1: } │{1: } |
- {1: }{4:int fact(int n) }│{1: }{2:-----------------}|
- {1: }{4:{ }│{1: }{2:-----------------}|
- {1: }{4: if(n > 1) }│{1: }{2:-----------------}|
- {1: }{4: { }│{1: }{2:-----------------}|
- {1: }{4: return fac}│{1: }{2:-----------------}|
- {1: }{4: } }│{1: }{2:-----------------}|
- {1: }{4: return 1; }│{1: }{2:-----------------}|
- {1: }{4:} }│{1: }{2:-----------------}|
- {1: }{4: }│{1: }{2:-----------------}|
- {1: }int main(int argc,│{1: }int main(int argc|
- {1: }{ │{1: }{ |
- {1: }{9: frobnitz(f}{8:act}{9:(}│{1: }{9: frobnitz(f}{8:ib}{9:(}|
- {1: }^} │{1: }} |
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- end)
- describe('diffopt+=indent-heuristic', function()
- setup(function()
- local f1 = [[
- def finalize(values)
- values.each do |v|
- v.finalize
- end]]
- write_file(fname, f1, false)
- local f2 = [[
- def finalize(values)
- values.each do |v|
- v.prepare
- end
- values.each do |v|
- v.finalize
- end]]
- write_file(fname_2, f2, false)
- feed(':diffupdate!<cr>')
- end)
- it('internal', function()
- reread()
- feed(":set diffopt=internal,filler<cr>")
- screen:expect([[
- {1: }^def finalize(value│{1: }def finalize(valu|
- {1: } │{1: } |
- {1: } values.each do |│{1: } values.each do |
- {1: }{2:------------------}│{1: }{4: v.prepare }|
- {1: }{2:------------------}│{1: }{4: end }|
- {1: }{2:------------------}│{1: }{4: }|
- {1: }{2:------------------}│{1: }{4: values.each do }|
- {1: } v.finalize │{1: } v.finalize |
- {1: } end │{1: } end |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler |
- ]])
- end)
- it('indent-heuristic', function()
- reread()
- feed(':set diffopt=internal,filler,indent-heuristic<cr>')
- screen:expect([[
- {1: }^def finalize(value│{1: }def finalize(valu|
- {1: } │{1: } |
- {1: }{2:------------------}│{1: }{4: values.each do }|
- {1: }{2:------------------}│{1: }{4: v.prepare }|
- {1: }{2:------------------}│{1: }{4: end }|
- {1: }{2:------------------}│{1: }{4: }|
- {1: } values.each do |│{1: } values.each do |
- {1: } v.finalize │{1: } v.finalize |
- {1: } end │{1: } end |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- end)
- it('indent-heuristic random order', function()
- reread()
- feed(':set diffopt=internal,filler,indent-heuristic,algorithm:patience<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^def finalize(value│{1: }def finalize(valu|
- {1: } │{1: } |
- {1: }{2:------------------}│{1: }{4: values.each do }|
- {1: }{2:------------------}│{1: }{4: v.prepare }|
- {1: }{2:------------------}│{1: }{4: end }|
- {1: }{2:------------------}│{1: }{4: }|
- {1: } values.each do |│{1: } values.each do |
- {1: } v.finalize │{1: } v.finalize |
- {1: } end │{1: } end |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- end)
- it('Diff the same file', function()
- write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1:+ }{5:^+-- 10 lines: 1···}│{1:+ }{5:+-- 10 lines: 1··}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1:+ }{5:^+-- 10 lines: 1···}│{1:+ }{5:+-- 10 lines: 1··}|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('Diff an empty file', function()
- write_file(fname, "", false)
- write_file(fname_2, "", false)
- reread()
- feed(':set diffopt=filler<cr>')
- screen:expect([[
- {1:- }^ │{1:- } |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1:- }^ │{1:- } |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- it('diffopt+=icase', function()
- write_file(fname, "a\nb\ncd\n", false)
- write_file(fname_2, "A\nb\ncDe\n", false)
- reread()
- feed(':set diffopt=filler,icase<cr>')
- screen:expect([[
- {1: }^a │{1: }A |
- {1: }b │{1: }b |
- {1: }{9:cd }│{1: }{9:cD}{8:e}{9: }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler,icase |
- ]])
- feed(':set diffopt+=internal<cr>')
- screen:expect([[
- {1: }^a │{1: }A |
- {1: }b │{1: }b |
- {1: }{9:cd }│{1: }{9:cD}{8:e}{9: }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=internal |
- ]])
- end)
- describe('diffopt+=iwhite', function()
- setup(function()
- local f1 = 'int main()\n{\n printf("Hello, World!");\n return 0;\n}\n'
- write_file(fname, f1, false)
- local f2 = 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n'
- write_file(fname_2, f2, false)
- feed(':diffupdate!<cr>')
- end)
- it('external', function()
- reread()
- feed(':set diffopt=filler,iwhite<cr>')
- screen:expect([[
- {1: }^int main() │{1: }int main() |
- {1: }{ │{1: }{ |
- {1: }{2:------------------}│{1: }{4: if (0) }|
- {1: }{2:------------------}│{1: }{4: { }|
- {1: } printf("Hello, │{1: } printf("Hel|
- {1: } return 0; │{1: } return 0; |
- {1: }{2:------------------}│{1: }{4: } }|
- {1: }} │{1: }} |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler,iwhite |
- ]])
- end)
- it('internal', function()
- reread()
- feed(':set diffopt=filler,iwhite,internal<cr>')
- screen:expect([[
- {1: }^int main() │{1: }int main() |
- {1: }{ │{1: }{ |
- {1: }{2:------------------}│{1: }{4: if (0) }|
- {1: }{2:------------------}│{1: }{4: { }|
- {1: } printf("Hello, │{1: } printf("Hel|
- {1: } return 0; │{1: } return 0; |
- {1: }{2:------------------}│{1: }{4: } }|
- {1: }} │{1: }} |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=filler,iwhite,internal |
- ]])
- end)
- end)
- describe('diffopt+=iblank', function()
- setup(function()
- write_file(fname, 'a\n\n \ncd\nef\nxxx\n', false)
- write_file(fname_2, 'a\ncd\n\nef\nyyy\n', false)
- feed(':diffupdate!<cr>')
- end)
- it('generic', function()
- reread()
- feed(':set diffopt=internal,filler,iblank<cr>')
- screen:expect([[
- {1: }^a │{1: }a |
- {1: }{4: }│{1: }{2:-----------------}|
- {1: }{4: }│{1: }{2:-----------------}|
- {1: }cd │{1: }cd |
- {1: }ef │{1: } |
- {1: }{8:xxx}{9: }│{1: }ef |
- {6:~ }│{1: }{8:yyy}{9: }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler,iblank |
- ]])
- end)
- it('diffopt+=iwhite', function()
- reread()
- feed(':set diffopt=internal,filler,iblank,iwhite<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a │{1: }a |
- {1: } │{1: }cd |
- {1: } │{1: } |
- {1: }cd │{1: }ef |
- {1: }ef │{1: }{8:yyy}{9: }|
- {1: }{8:xxx}{9: }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- it('diffopt+=iwhiteall', function()
- reread()
- feed(':set diffopt=internal,filler,iblank,iwhiteall<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a │{1: }a |
- {1: } │{1: }cd |
- {1: } │{1: } |
- {1: }cd │{1: }ef |
- {1: }ef │{1: }{8:yyy}{9: }|
- {1: }{8:xxx}{9: }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- it('diffopt+=iwhiteeol', function()
- reread()
- feed(':set diffopt=internal,filler,iblank,iwhiteeol<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a │{1: }a |
- {1: } │{1: }cd |
- {1: } │{1: } |
- {1: }cd │{1: }ef |
- {1: }ef │{1: }{8:yyy}{9: }|
- {1: }{8:xxx}{9: }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- end)
- describe('diffopt+=iwhite{eol,all}', function()
- setup(function()
- write_file(fname, 'a \nx\ncd\nef\nxx xx\nfoo\nbar\n', false)
- write_file(fname_2, 'a\nx\nc d\n ef\nxx xx\nfoo\n\nbar\n', false)
- feed(':diffupdate!<cr>')
- end)
- it('diffopt+=iwhiteeol', function()
- reread()
- feed(':set diffopt=internal,filler,iwhiteeol<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a │{1: }a |
- {1: }x │{1: }x |
- {1: }{9:cd }│{1: }{9:c}{8: }{9:d }|
- {1: }{9:ef }│{1: }{8: }{9:ef }|
- {1: }{9:xx }{8: }{9:xx }│{1: }{9:xx xx }|
- {1: }foo │{1: }foo |
- {1: }{2:------------------}│{1: }{4: }|
- {1: }bar │{1: }bar |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- it('diffopt+=iwhiteall', function()
- reread()
- feed(':set diffopt=internal,filler,iwhiteall<cr>')
- feed(':<cr>')
- screen:expect([[
- {1: }^a │{1: }a |
- {1: }x │{1: }x |
- {1: }cd │{1: }c d |
- {1: }ef │{1: } ef |
- {1: }xx xx │{1: }xx xx |
- {1: }foo │{1: }foo |
- {1: }{2:------------------}│{1: }{4: }|
- {1: }bar │{1: }bar |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- : |
- ]])
- end)
- end)
- -- oldtest: Test_diff_scroll()
- -- This was scrolling for 'cursorbind' but 'scrollbind' is more important
- it('scrolling works correctly vim-patch:8.2.5155', function()
- screen:try_resize(40, 12)
- write_file(fname, dedent([[
- line 1
- line 2
- line 3
- line 4
- // Common block
- // one
- // containing
- // four lines
- // Common block
- // two
- // containing
- // four lines]]), false)
- write_file(fname_2, dedent([[
- line 1
- line 2
- line 3
- line 4
- Lorem
- ipsum
- dolor
- sit
- amet,
- consectetur
- adipiscing
- elit.
- Etiam
- luctus
- lectus
- sodales,
- dictum
- // Common block
- // one
- // containing
- // four lines
- Vestibulum
- tincidunt
- aliquet
- nulla.
- // Common block
- // two
- // containing
- // four lines]]), false)
- reread()
- feed('<C-W><C-W>jjjj')
- screen:expect([[
- {1: }line 1 │{1: }line 1 |
- {1: }line 2 │{1: }line 2 |
- {1: }line 3 │{1: }line 3 |
- {1: }line 4 │{1: }line 4 |
- {1: } │{1: }^ |
- {1: }{2:-----------------}│{1: }{4:Lorem }|
- {1: }{2:-----------------}│{1: }{4:ipsum }|
- {1: }{2:-----------------}│{1: }{4:dolor }|
- {1: }{2:-----------------}│{1: }{4:sit }|
- {1: }{2:-----------------}│{1: }{4:amet, }|
- {3:<nal-diff-screen-1 }{7:<al-diff-screen-1.2 }|
- :e |
- ]])
- feed('j')
- screen:expect([[
- {1: }line 1 │{1: }line 1 |
- {1: }line 2 │{1: }line 2 |
- {1: }line 3 │{1: }line 3 |
- {1: }line 4 │{1: }line 4 |
- {1: } │{1: } |
- {1: }{2:-----------------}│{1: }{4:^Lorem }|
- {1: }{2:-----------------}│{1: }{4:ipsum }|
- {1: }{2:-----------------}│{1: }{4:dolor }|
- {1: }{2:-----------------}│{1: }{4:sit }|
- {1: }{2:-----------------}│{1: }{4:amet, }|
- {3:<nal-diff-screen-1 }{7:<al-diff-screen-1.2 }|
- :e |
- ]])
- end)
- describe('line matching diff algorithm', function()
- setup(function()
- local f1 = [[if __name__ == "__main__":
- import sys
- app = QWidgets.QApplication(sys.args)
- MainWindow = QtWidgets.QMainWindow()
- ui = UI_MainWindow()
- ui.setupUI(MainWindow)
- MainWindow.show()
- sys.exit(app.exec_())]]
- write_file(fname, f1, false)
- local f2 = [[if __name__ == "__main__":
- import sys
- comment these things
- #app = QWidgets.QApplication(sys.args)
- #MainWindow = QtWidgets.QMainWindow()
- add a completely different line here
- #ui = UI_MainWindow()
- add another new line
- ui.setupUI(MainWindow)
- MainWindow.show()
- sys.exit(app.exec_())]]
- write_file(fname_2, f2, false)
- end)
- it('diffopt+=linematch:20', function()
- reread()
- feed(':set diffopt=internal,filler<cr>')
- screen:expect([[
- {1: }^if __name__ == "__│{1: }if __name__ == "_|
- {1: } import sys │{1: } import sys |
- {1: }{9: }{8:app = QWidgets}│{1: }{9: }{8:comment these}|
- {1: }{9: }{8:MainWindow = Q}│{1: }{9: }{8:#app = QWidge}|
- {1: }{9: }{8:ui = UI_}{9:MainWi}│{1: }{9: }{8:#MainWindow =}|
- {1: }{2:------------------}│{1: }{4: add a complet}|
- {1: }{2:------------------}│{1: }{4: #ui = UI_Main}|
- {1: }{2:------------------}│{1: }{4: add another n}|
- {1: } ui.setupUI(Mai│{1: } ui.setupUI(Ma|
- {1: } MainWindow.sho│{1: } MainWindow.sh|
- {1: } sys.exit(app.e│{1: } sys.exit(app.|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt=internal,filler |
- ]])
- feed('G')
- feed(':set diffopt+=linematch:20<cr>')
- screen:expect([[
- {1: }if __name__ == "__│{1: }if __name__ == "_|
- {1: } import sys │{1: } import sys |
- {1: }{2:------------------}│{1: }{4: comment these}|
- {1: }{9: app = QWidgets}│{1: }{9: }{8:#}{9:app = QWidge}|
- {1: }{9: MainWindow = Q}│{1: }{9: }{8:#}{9:MainWindow =}|
- {1: }{2:------------------}│{1: }{4: add a complet}|
- {1: }{9: ui = UI_MainWi}│{1: }{9: }{8:#}{9:ui = UI_Main}|
- {1: }{2:------------------}│{1: }{4: add another n}|
- {1: } ui.setupUI(Mai│{1: } ui.setupUI(Ma|
- {1: } MainWindow.sho│{1: } MainWindow.sh|
- {1: } ^sys.exit(app.e│{1: } sys.exit(app.|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=linematch:20 |
- ]])
- end)
- end)
- describe('line matching diff algorithm with icase', function()
- setup(function()
- local f1 = [[DDD
- _aa]]
- write_file(fname, f1, false)
- local f2 = [[DDD
- AAA
- ccca]]
- write_file(fname_2, f2, false)
- end)
- it('diffopt+=linematch:20,icase', function()
- reread()
- feed(':set diffopt=internal,filler,linematch:20<cr>')
- screen:expect([[
- {1: }^DDD │{1: }DDD |
- {1: }{2:------------------}│{1: }{4:AAA }|
- {1: }{8:_a}{9:a }│{1: }{8:ccc}{9:a }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]])
- feed(':set diffopt+=icase<cr>')
- screen:expect([[
- {1: }^DDD │{1: }DDD |
- {1: }{8:_}{9:aa }│{1: }{8:A}{9:AA }|
- {1: }{2:------------------}│{1: }{4:ccca }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=icase |
- ]])
- end)
- end)
- describe('line matching diff algorithm with iwhiteall', function()
- setup(function()
- local f1 = [[BB
- AAA]]
- write_file(fname, f1, false)
- local f2 = [[BB
- AAB
- AAAB]]
- write_file(fname_2, f2, false)
- end)
- it('diffopt+=linematch:20,iwhiteall', function()
- reread()
- feed(':set diffopt=internal,filler,linematch:20<cr>')
- screen:expect{grid=[[
- {1: }^BB │{1: }BB |
- {1: }{9: AA}{8:A}{9: }│{1: }{9: AA}{8:B}{9: }|
- {1: }{2:------------------}│{1: }{4:AAAB }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- |
- ]]}
- feed(':set diffopt+=iwhiteall<cr>')
- screen:expect{grid=[[
- {1: }^BB │{1: }BB |
- {1: }{2:------------------}│{1: }{4: AAB }|
- {1: }{9: AAA }│{1: }{9:AAA}{8:B}{9: }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
- :set diffopt+=iwhiteall |
- ]]}
- end)
- end)
- end)
- it('win_update redraws lines properly', function()
- local screen
- screen = Screen.new(50, 10)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [3] = {background = Screen.colors.Red, foreground = Screen.colors.Grey100, special = Screen.colors.Yellow},
- [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [5] = {special = Screen.colors.Yellow},
- [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4},
- [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100},
- [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100},
- [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100},
- [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')},
- [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452')},
- [12] = {bold = true, reverse = true},
- [13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [14] = {reverse = true},
- [15] = {background = Screen.colors.LightBlue},
- [16] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [17] = {bold = true, background = Screen.colors.Red},
- [18] = {background = Screen.colors.LightMagenta},
- })
- insert([[
- 1
- 2
- 1a
- ]])
- command("vnew left")
- insert([[
- 2
- 2a
- 2b
- ]])
- command("windo diffthis")
- command("windo 1")
- screen:expect{grid=[[
- {13: }{16:-----------------------}│{13: }{15:^1 }|
- {13: }{16:-----------------------}│{13: }{15: }|
- {13: }{16:-----------------------}│{13: }{15: }|
- {13: }2 │{13: }2 |
- {13: }{17:2}{18:a }│{13: }{17:1}{18:a }|
- {13: }{15:2b }│{13: }{16:----------------------}|
- {13: } │{13: } |
- {1:~ }│{1:~ }|
- {14:left [+] }{12:[No Name] [+] }|
- |
- ]]}
- feed('<C-e>')
- feed('<C-e>')
- feed('<C-y>')
- feed('<C-y>')
- feed('<C-y>')
- screen:expect{grid=[[
- {13: }{16:-----------------------}│{13: }{15:1 }|
- {13: }{16:-----------------------}│{13: }{15: }|
- {13: }{16:-----------------------}│{13: }{15:^ }|
- {13: }2 │{13: }2 |
- {13: }{17:2}{18:a }│{13: }{17:1}{18:a }|
- {13: }{15:2b }│{13: }{16:----------------------}|
- {13: } │{13: } |
- {1:~ }│{1:~ }|
- {14:left [+] }{12:[No Name] [+] }|
- |
- ]]}
- end)
- -- oldtest: Test_diff_rnu()
- it('diff updates line numbers below filler lines', function()
- local screen = Screen.new(40, 14)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
- [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
- [3] = {reverse = true},
- [4] = {background = Screen.colors.LightBlue},
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
- [6] = {bold = true, foreground = Screen.colors.Blue1},
- [7] = {bold = true, reverse = true},
- [8] = {bold = true, background = Screen.colors.Red},
- [9] = {background = Screen.colors.LightMagenta},
- [10] = {bold = true, foreground = Screen.colors.Brown},
- [11] = {foreground = Screen.colors.Brown},
- })
- exec([[
- call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
- vnew
- call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
- windo diffthis
- setlocal number rnu cursorline cursorlineopt=number foldcolumn=0
- ]])
- screen:expect([[
- {1: }a │{10:1 }^a |
- {1: }a │{11: 1 }a |
- {1: }a │{11: 2 }a |
- {1: }{8:x}{9: }│{11: 3 }{8:y}{9: }|
- {1: }{4:x }│{11: }{2:----------------}|
- {1: }{4:x }│{11: }{2:----------------}|
- {1: }b │{11: 4 }b |
- {1: }b │{11: 5 }b |
- {1: }b │{11: 6 }b |
- {1: }b │{11: 7 }b |
- {1: }b │{11: 8 }b |
- {6:~ }│{6:~ }|
- {3:[No Name] [+] }{7:[No Name] [+] }|
- |
- ]])
- feed('j')
- screen:expect([[
- {1: }a │{11: 1 }a |
- {1: }a │{10:2 }^a |
- {1: }a │{11: 1 }a |
- {1: }{8:x}{9: }│{11: 2 }{8:y}{9: }|
- {1: }{4:x }│{11: }{2:----------------}|
- {1: }{4:x }│{11: }{2:----------------}|
- {1: }b │{11: 3 }b |
- {1: }b │{11: 4 }b |
- {1: }b │{11: 5 }b |
- {1: }b │{11: 6 }b |
- {1: }b │{11: 7 }b |
- {6:~ }│{6:~ }|
- {3:[No Name] [+] }{7:[No Name] [+] }|
- |
- ]])
- feed('j')
- screen:expect([[
- {1: }a │{11: 2 }a |
- {1: }a │{11: 1 }a |
- {1: }a │{10:3 }^a |
- {1: }{8:x}{9: }│{11: 1 }{8:y}{9: }|
- {1: }{4:x }│{11: }{2:----------------}|
- {1: }{4:x }│{11: }{2:----------------}|
- {1: }b │{11: 2 }b |
- {1: }b │{11: 3 }b |
- {1: }b │{11: 4 }b |
- {1: }b │{11: 5 }b |
- {1: }b │{11: 6 }b |
- {6:~ }│{6:~ }|
- {3:[No Name] [+] }{7:[No Name] [+] }|
- |
- ]])
- end)
- -- oldtest: Test_diff_with_scroll_and_change()
- it('Align the filler lines when changing text in diff mode', function()
- local screen = Screen.new(40, 20)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1, bold = true};
- [3] = {reverse = true};
- [4] = {background = Screen.colors.LightBlue};
- [5] = {background = Screen.colors.LightMagenta};
- [6] = {background = Screen.colors.Red, bold = true};
- [7] = {foreground = Screen.colors.Blue1, bold = true};
- [8] = {reverse = true, bold = true};
- })
- exec([[
- call setline(1, range(1, 15))
- vnew
- call setline(1, range(9, 15))
- windo diffthis
- wincmd h
- exe "normal Gl5\<C-E>"
- ]])
- screen:expect{grid=[[
- {1: }{2:------------------}│{1: }{4:6 }|
- {1: }{2:------------------}│{1: }{4:7 }|
- {1: }{2:------------------}│{1: }{4:8 }|
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }11 │{1: }11 |
- {1: }12 │{1: }12 |
- {1: }13 │{1: }13 |
- {1: }14 │{1: }14 |
- {1:- }1^5 │{1:- }15 |
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {8:[No Name] [+] }{3:[No Name] [+] }|
- |
- ]]}
- feed('ax<Esc>')
- screen:expect{grid=[[
- {1: }{2:------------------}│{1: }{4:6 }|
- {1: }{2:------------------}│{1: }{4:7 }|
- {1: }{2:------------------}│{1: }{4:8 }|
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }11 │{1: }11 |
- {1: }12 │{1: }12 |
- {1: }13 │{1: }13 |
- {1: }14 │{1: }14 |
- {1: }{5:15}{6:^x}{5: }│{1: }{5:15 }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {8:[No Name] [+] }{3:[No Name] [+] }|
- |
- ]]}
- feed('<C-W>lay<Esc>')
- screen:expect{grid=[[
- {1: }{2:-----------------}│{1: }{4:6 }|
- {1: }{2:-----------------}│{1: }{4:7 }|
- {1: }{2:-----------------}│{1: }{4:8 }|
- {1: }9 │{1: }9 |
- {1: }10 │{1: }10 |
- {1: }11 │{1: }11 |
- {1: }12 │{1: }12 |
- {1: }13 │{1: }13 |
- {1: }14 │{1: }14 |
- {1: }{5:15}{6:x}{5: }│{1: }{5:15}{6:^y}{5: }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {7:~ }│{7:~ }|
- {3:[No Name] [+] }{8:[No Name] [+] }|
- |
- ]]}
- end)
- it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function()
- local screen = Screen.new(60, 6)
- screen:set_default_attr_ids({
- [0] = {foreground = Screen.colors.Blue, bold = true};
- })
- screen:attach()
- eq('0', meths.get_option_value('foldcolumn', {}))
- command('diffsplit | bd')
- screen:expect([[
- ^ |
- {0:~ }|
- {0:~ }|
- {0:~ }|
- {0:~ }|
- |
- ]])
- eq('0', meths.get_option_value('foldcolumn', {}))
- end)
- -- oldtest: Test_diff_binary()
- it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
- local screen = Screen.new(40, 20)
- screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {reverse = true};
- [3] = {background = Screen.colors.LightBlue};
- [4] = {background = Screen.colors.LightMagenta};
- [5] = {background = Screen.colors.Red, bold = true};
- [6] = {foreground = Screen.colors.Blue, bold = true};
- [7] = {background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true};
- [8] = {reverse = true, bold = true};
- })
- screen:attach()
- exec([[
- call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g'])
- vnew
- call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g'])
- windo diffthis
- wincmd p
- norm! gg0
- redraw!
- ]])
- -- Test using internal diff
- screen:expect([[
- {1: }{5:^A}{4: }│{1: }{5:a}{4: }|
- {1: }b │{1: }b |
- {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
- {1: }d │{1: }d |
- {1: }{5:E}{4: }│{1: }{5:e}{4: }|
- {1: }f │{1: }f |
- {1: }g │{1: }g |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {8:[No Name] [+] }{2:[No Name] [+] }|
- |
- ]])
- -- Test using internal diff and case folding
- command('set diffopt+=icase')
- feed('<C-L>')
- screen:expect([[
- {1: }^A │{1: }a |
- {1: }b │{1: }b |
- {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
- {1: }d │{1: }d |
- {1: }E │{1: }e |
- {1: }f │{1: }f |
- {1: }g │{1: }g |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {8:[No Name] [+] }{2:[No Name] [+] }|
- |
- ]])
- -- Test using external diff
- command('set diffopt=filler')
- feed('<C-L>')
- screen:expect([[
- {1: }{5:^A}{4: }│{1: }{5:a}{4: }|
- {1: }b │{1: }b |
- {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
- {1: }d │{1: }d |
- {1: }{5:E}{4: }│{1: }{5:e}{4: }|
- {1: }f │{1: }f |
- {1: }g │{1: }g |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {8:[No Name] [+] }{2:[No Name] [+] }|
- |
- ]])
- -- Test using external diff and case folding
- command('set diffopt+=filler,icase')
- feed('<C-L>')
- screen:expect([[
- {1: }^A │{1: }a |
- {1: }b │{1: }b |
- {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
- {1: }d │{1: }d |
- {1: }E │{1: }e |
- {1: }f │{1: }f |
- {1: }g │{1: }g |
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {6:~ }│{6:~ }|
- {8:[No Name] [+] }{2:[No Name] [+] }|
- |
- ]])
- end)
- -- oldtest: Test_diff_breakindent_after_filler()
- it("diff mode draws 'breakindent' correctly after filler lines", function()
- local screen = Screen.new(45, 8)
- screen:attach()
- screen:set_default_attr_ids({
- [1] = {background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue};
- [2] = {background = Screen.colors.LightBlue};
- [3] = {background = Screen.colors.LightCyan, bold = true, foreground = Screen.colors.Blue};
- [4] = {foreground = Screen.colors.Blue, bold = true};
- })
- exec([[
- set laststatus=0 diffopt+=followwrap breakindent
- call setline(1, ['a', ' ' .. repeat('c', 50)])
- vnew
- call setline(1, ['a', 'b', ' ' .. repeat('c', 50)])
- windo diffthis
- norm! G$
- ]])
- screen:expect([[
- {1: }a │{1: }a |
- {1: }{2:b }│{1: }{3:--------------------}|
- {1: } cccccccccccccccccc│{1: } cccccccccccccccccc|
- {1: } cccccccccccccccccc│{1: } cccccccccccccccccc|
- {1: } cccccccccccccc │{1: } ccccccccccccc^c |
- {4:~ }│{4:~ }|
- {4:~ }│{4:~ }|
- |
- ]])
- end)
|