diff_spec.lua 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local Screen = require('test.functional.ui.screen')
  4. local feed = n.feed
  5. local clear = n.clear
  6. local command = n.command
  7. local insert = n.insert
  8. local write_file = t.write_file
  9. local dedent = t.dedent
  10. local exec = n.exec
  11. local eq = t.eq
  12. local api = n.api
  13. local function WriteDiffFiles(text1, text2)
  14. write_file('Xdifile1', text1)
  15. write_file('Xdifile2', text2)
  16. command('checktime')
  17. end
  18. local function WriteDiffFiles3(text1, text2, text3)
  19. write_file('Xdifile1', text1)
  20. write_file('Xdifile2', text2)
  21. write_file('Xdifile3', text3)
  22. command('checktime')
  23. end
  24. before_each(clear)
  25. describe('Diff mode screen', function()
  26. local fname = 'Xtest-functional-diff-screen-1'
  27. local fname_2 = fname .. '.2'
  28. local screen
  29. local reread = function()
  30. feed(':e<cr><c-w>w:e<cr><c-w>w')
  31. end
  32. setup(function()
  33. os.remove(fname)
  34. os.remove(fname_2)
  35. end)
  36. teardown(function()
  37. os.remove(fname)
  38. os.remove(fname_2)
  39. end)
  40. before_each(function()
  41. feed(':e ' .. fname_2 .. '<cr>')
  42. feed(':vnew ' .. fname .. '<cr>')
  43. feed(':diffthis<cr>')
  44. feed('<c-w>w:diffthis<cr><c-w>w')
  45. screen = Screen.new(40, 16)
  46. end)
  47. it('Add a line in beginning of file 2', function()
  48. write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  49. write_file(fname_2, '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  50. reread()
  51. feed(':set diffopt=filler<cr>')
  52. screen:expect([[
  53. {7: }{23:------------------}│{7: }{22:0 }|
  54. {7: }^1 │{7: }1 |
  55. {7: }2 │{7: }2 |
  56. {7: }3 │{7: }3 |
  57. {7: }4 │{7: }4 |
  58. {7: }5 │{7: }5 |
  59. {7: }6 │{7: }6 |
  60. {7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}|
  61. {1:~ }│{1:~ }|*6
  62. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  63. :set diffopt=filler |
  64. ]])
  65. feed(':set diffopt+=internal<cr>')
  66. screen:expect([[
  67. {7: }{23:------------------}│{7: }{22:0 }|
  68. {7: }^1 │{7: }1 |
  69. {7: }2 │{7: }2 |
  70. {7: }3 │{7: }3 |
  71. {7: }4 │{7: }4 |
  72. {7: }5 │{7: }5 |
  73. {7: }6 │{7: }6 |
  74. {7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}|
  75. {1:~ }│{1:~ }|*6
  76. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  77. :set diffopt+=internal |
  78. ]])
  79. end)
  80. it('Add a line in beginning of file 1', function()
  81. write_file(fname, '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  82. write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  83. reread()
  84. feed(':set diffopt=filler<cr>')
  85. screen:expect([[
  86. {7: }{22:^0 }│{7: }{23:-----------------}|
  87. {7: }1 │{7: }1 |
  88. {7: }2 │{7: }2 |
  89. {7: }3 │{7: }3 |
  90. {7: }4 │{7: }4 |
  91. {7: }5 │{7: }5 |
  92. {7: }6 │{7: }6 |
  93. {7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}|
  94. {1:~ }│{1:~ }|*6
  95. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  96. :set diffopt=filler |
  97. ]])
  98. feed(':set diffopt+=internal<cr>')
  99. screen:expect([[
  100. {7: }{22:^0 }│{7: }{23:-----------------}|
  101. {7: }1 │{7: }1 |
  102. {7: }2 │{7: }2 |
  103. {7: }3 │{7: }3 |
  104. {7: }4 │{7: }4 |
  105. {7: }5 │{7: }5 |
  106. {7: }6 │{7: }6 |
  107. {7:+ }{13:+-- 4 lines: 7···}│{7:+ }{13:+-- 4 lines: 7··}|
  108. {1:~ }│{1:~ }|*6
  109. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  110. :set diffopt+=internal |
  111. ]])
  112. end)
  113. it('Add a line at the end of file 2', function()
  114. write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  115. write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
  116. reread()
  117. feed(':set diffopt=filler<cr>')
  118. screen:expect([[
  119. {7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}|
  120. {7: }5 │{7: }5 |
  121. {7: }6 │{7: }6 |
  122. {7: }7 │{7: }7 |
  123. {7: }8 │{7: }8 |
  124. {7: }9 │{7: }9 |
  125. {7: }10 │{7: }10 |
  126. {7: }{23:------------------}│{7: }{22:11 }|
  127. {1:~ }│{1:~ }|*6
  128. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  129. :set diffopt=filler |
  130. ]])
  131. feed(':set diffopt+=internal<cr>')
  132. screen:expect([[
  133. {7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}|
  134. {7: }5 │{7: }5 |
  135. {7: }6 │{7: }6 |
  136. {7: }7 │{7: }7 |
  137. {7: }8 │{7: }8 |
  138. {7: }9 │{7: }9 |
  139. {7: }10 │{7: }10 |
  140. {7: }{23:------------------}│{7: }{22:11 }|
  141. {1:~ }│{1:~ }|*6
  142. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  143. :set diffopt+=internal |
  144. ]])
  145. screen:try_resize(40, 9)
  146. screen:expect([[
  147. {7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}|
  148. {7: }5 │{7: }5 |
  149. {7: }6 │{7: }6 |
  150. {7: }7 │{7: }7 |
  151. {7: }8 │{7: }8 |
  152. {7: }9 │{7: }9 |
  153. {7: }10 │{7: }10 |
  154. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  155. |
  156. ]])
  157. end)
  158. it('Add a line at the end of file 1', function()
  159. write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
  160. write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  161. reread()
  162. feed(':set diffopt=filler<cr>')
  163. screen:expect([[
  164. {7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}|
  165. {7: }5 │{7: }5 |
  166. {7: }6 │{7: }6 |
  167. {7: }7 │{7: }7 |
  168. {7: }8 │{7: }8 |
  169. {7: }9 │{7: }9 |
  170. {7: }10 │{7: }10 |
  171. {7: }{22:11 }│{7: }{23:-----------------}|
  172. {1:~ }│{1:~ }|*6
  173. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  174. :set diffopt=filler |
  175. ]])
  176. feed(':set diffopt+=internal<cr>')
  177. screen:expect([[
  178. {7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}|
  179. {7: }5 │{7: }5 |
  180. {7: }6 │{7: }6 |
  181. {7: }7 │{7: }7 |
  182. {7: }8 │{7: }8 |
  183. {7: }9 │{7: }9 |
  184. {7: }10 │{7: }10 |
  185. {7: }{22:11 }│{7: }{23:-----------------}|
  186. {1:~ }│{1:~ }|*6
  187. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  188. :set diffopt+=internal |
  189. ]])
  190. screen:try_resize(40, 9)
  191. screen:expect([[
  192. {7:+ }{13:^+-- 4 lines: 1···}│{7:+ }{13:+-- 4 lines: 1··}|
  193. {7: }5 │{7: }5 |
  194. {7: }6 │{7: }6 |
  195. {7: }7 │{7: }7 |
  196. {7: }8 │{7: }8 |
  197. {7: }9 │{7: }9 |
  198. {7: }10 │{7: }10 |
  199. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  200. |
  201. ]])
  202. end)
  203. it('Add a line in the middle of file 2, remove on at the end of file 1', function()
  204. write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
  205. write_file(fname_2, '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n', false)
  206. reread()
  207. feed(':set diffopt=filler<cr>')
  208. screen:expect([[
  209. {7: }^1 │{7: }1 |
  210. {7: }2 │{7: }2 |
  211. {7: }3 │{7: }3 |
  212. {7: }4 │{7: }4 |
  213. {7: }{23:------------------}│{7: }{22:4 }|
  214. {7: }5 │{7: }5 |
  215. {7: }6 │{7: }6 |
  216. {7: }7 │{7: }7 |
  217. {7: }8 │{7: }8 |
  218. {7: }9 │{7: }9 |
  219. {7: }10 │{7: }10 |
  220. {7: }{22:11 }│{7: }{23:-----------------}|
  221. {1:~ }│{1:~ }|*2
  222. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  223. :set diffopt=filler |
  224. ]])
  225. feed(':set diffopt+=internal<cr>')
  226. screen:expect([[
  227. {7: }^1 │{7: }1 |
  228. {7: }2 │{7: }2 |
  229. {7: }3 │{7: }3 |
  230. {7: }4 │{7: }4 |
  231. {7: }{23:------------------}│{7: }{22:4 }|
  232. {7: }5 │{7: }5 |
  233. {7: }6 │{7: }6 |
  234. {7: }7 │{7: }7 |
  235. {7: }8 │{7: }8 |
  236. {7: }9 │{7: }9 |
  237. {7: }10 │{7: }10 |
  238. {7: }{22:11 }│{7: }{23:-----------------}|
  239. {1:~ }│{1:~ }|*2
  240. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  241. :set diffopt+=internal |
  242. ]])
  243. end)
  244. it('Add a line in the middle of file 1, remove on at the end of file 2', function()
  245. write_file(fname, '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n', false)
  246. write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false)
  247. reread()
  248. feed(':set diffopt=filler<cr>')
  249. screen:expect([[
  250. {7: }^1 │{7: }1 |
  251. {7: }2 │{7: }2 |
  252. {7: }3 │{7: }3 |
  253. {7: }4 │{7: }4 |
  254. {7: }{22:4 }│{7: }{23:-----------------}|
  255. {7: }5 │{7: }5 |
  256. {7: }6 │{7: }6 |
  257. {7: }7 │{7: }7 |
  258. {7: }8 │{7: }8 |
  259. {7: }9 │{7: }9 |
  260. {7: }10 │{7: }10 |
  261. {7: }{23:------------------}│{7: }{22:11 }|
  262. {1:~ }│{1:~ }|*2
  263. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  264. :set diffopt=filler |
  265. ]])
  266. feed(':set diffopt+=internal<cr>')
  267. screen:expect([[
  268. {7: }^1 │{7: }1 |
  269. {7: }2 │{7: }2 |
  270. {7: }3 │{7: }3 |
  271. {7: }4 │{7: }4 |
  272. {7: }{22:4 }│{7: }{23:-----------------}|
  273. {7: }5 │{7: }5 |
  274. {7: }6 │{7: }6 |
  275. {7: }7 │{7: }7 |
  276. {7: }8 │{7: }8 |
  277. {7: }9 │{7: }9 |
  278. {7: }10 │{7: }10 |
  279. {7: }{23:------------------}│{7: }{22:11 }|
  280. {1:~ }│{1:~ }|*2
  281. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  282. :set diffopt+=internal |
  283. ]])
  284. end)
  285. describe('normal/patience/histogram diff algorithm', function()
  286. setup(function()
  287. local f1 = [[#include <stdio.h>
  288. // Frobs foo heartily
  289. int frobnitz(int foo)
  290. {
  291. int i;
  292. for(i = 0; i < 10; i++)
  293. {
  294. printf("Your answer is: ");
  295. printf("%d\n", foo);
  296. }
  297. }
  298. int fact(int n)
  299. {
  300. if(n > 1)
  301. {
  302. return fact(n-1) * n;
  303. }
  304. return 1;
  305. }
  306. int main(int argc, char **argv)
  307. {
  308. frobnitz(fact(10));
  309. }]]
  310. write_file(fname, f1, false)
  311. local f2 = [[#include <stdio.h>
  312. int fib(int n)
  313. {
  314. if(n > 2)
  315. {
  316. return fib(n-1) + fib(n-2);
  317. }
  318. return 1;
  319. }
  320. // Frobs foo heartily
  321. int frobnitz(int foo)
  322. {
  323. int i;
  324. for(i = 0; i < 10; i++)
  325. {
  326. printf("%d\n", foo);
  327. }
  328. }
  329. int main(int argc, char **argv)
  330. {
  331. frobnitz(fib(10));
  332. }]]
  333. write_file(fname_2, f2, false)
  334. end)
  335. it('diffopt=+algorithm:myers', function()
  336. reread()
  337. feed(':set diffopt=internal,filler<cr>')
  338. screen:expect([[
  339. {7: }^#include <stdio.h>│{7: }#include <stdio.h|
  340. {7: } │{7: } |
  341. {7: }{27:// Frobs foo heart}│{7: }{27:int fib(int n)}{4: }|
  342. {7: }{22:int frobnitz(int f}│{7: }{23:-----------------}|
  343. {7: }{ │{7: }{ |
  344. {7: }{4: i}{27:nt i;}{4: }│{7: }{4: i}{27:f(n > 2)}{4: }|
  345. {7: }{22: for(i = 0; i <}│{7: }{23:-----------------}|
  346. {7: } { │{7: } { |
  347. {7: }{4: }{27:printf("Yo}│{7: }{4: }{27:return fi}|
  348. {7: }{22: printf("%d}│{7: }{23:-----------------}|
  349. {7: } } │{7: } } |
  350. {7: }{23:------------------}│{7: }{22: return 1; }|
  351. {7: }} │{7: }} |
  352. {7: } │{7: } |
  353. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  354. :set diffopt=internal,filler |
  355. ]])
  356. feed('G')
  357. screen:expect([[
  358. {7: }{23:------------------}│{7: }{22:int frobnitz(int }|
  359. {7: }{ │{7: }{ |
  360. {7: }{4: i}{27:f(n > 1)}{4: }│{7: }{4: i}{27:nt i;}{4: }|
  361. {7: }{23:------------------}│{7: }{22: for(i = 0; i }|
  362. {7: } { │{7: } { |
  363. {7: }{4: }{27:return fac}│{7: }{4: }{27:printf("%}|
  364. {7: } } │{7: } } |
  365. {7: }{22: return 1; }│{7: }{23:-----------------}|
  366. {7: }} │{7: }} |
  367. {7: } │{7: } |
  368. {7: }int main(int argc,│{7: }int main(int argc|
  369. {7: }{ │{7: }{ |
  370. {7: }{4: frobnitz(f}{27:act}{4:(}│{7: }{4: frobnitz(f}{27:ib}{4:(}|
  371. {7: }^} │{7: }} |
  372. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  373. :set diffopt=internal,filler |
  374. ]])
  375. end)
  376. it('diffopt+=algorithm:patience', function()
  377. reread()
  378. feed(':set diffopt=internal,filler,algorithm:patience<cr>')
  379. screen:expect([[
  380. {7: }^#include <stdio.h>│{7: }#include <stdio.h|
  381. {7: } │{7: } |
  382. {7: }{23:------------------}│{7: }{22:int fib(int n) }|
  383. {7: }{23:------------------}│{7: }{22:{ }|
  384. {7: }{23:------------------}│{7: }{22: if(n > 2) }|
  385. {7: }{23:------------------}│{7: }{22: { }|
  386. {7: }{23:------------------}│{7: }{22: return fi}|
  387. {7: }{23:------------------}│{7: }{22: } }|
  388. {7: }{23:------------------}│{7: }{22: return 1; }|
  389. {7: }{23:------------------}│{7: }{22:} }|
  390. {7: }{23:------------------}│{7: }{22: }|
  391. {7: }// Frobs foo heart│{7: }// Frobs foo hear|
  392. {7: }int frobnitz(int f│{7: }int frobnitz(int |
  393. {7: }{ │{7: }{ |
  394. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  395. |
  396. ]])
  397. feed('G')
  398. screen:expect([[
  399. {7: } │{7: } |
  400. {7: }{22:int fact(int n) }│{7: }{23:-----------------}|
  401. {7: }{22:{ }│{7: }{23:-----------------}|
  402. {7: }{22: if(n > 1) }│{7: }{23:-----------------}|
  403. {7: }{22: { }│{7: }{23:-----------------}|
  404. {7: }{22: return fac}│{7: }{23:-----------------}|
  405. {7: }{22: } }│{7: }{23:-----------------}|
  406. {7: }{22: return 1; }│{7: }{23:-----------------}|
  407. {7: }{22:} }│{7: }{23:-----------------}|
  408. {7: }{22: }│{7: }{23:-----------------}|
  409. {7: }int main(int argc,│{7: }int main(int argc|
  410. {7: }{ │{7: }{ |
  411. {7: }{4: frobnitz(f}{27:act}{4:(}│{7: }{4: frobnitz(f}{27:ib}{4:(}|
  412. {7: }^} │{7: }} |
  413. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  414. |
  415. ]])
  416. end)
  417. it('diffopt+=algorithm:histogram', function()
  418. reread()
  419. feed(':set diffopt=internal,filler,algorithm:histogram<cr>')
  420. screen:expect([[
  421. {7: }^#include <stdio.h>│{7: }#include <stdio.h|
  422. {7: } │{7: } |
  423. {7: }{23:------------------}│{7: }{22:int fib(int n) }|
  424. {7: }{23:------------------}│{7: }{22:{ }|
  425. {7: }{23:------------------}│{7: }{22: if(n > 2) }|
  426. {7: }{23:------------------}│{7: }{22: { }|
  427. {7: }{23:------------------}│{7: }{22: return fi}|
  428. {7: }{23:------------------}│{7: }{22: } }|
  429. {7: }{23:------------------}│{7: }{22: return 1; }|
  430. {7: }{23:------------------}│{7: }{22:} }|
  431. {7: }{23:------------------}│{7: }{22: }|
  432. {7: }// Frobs foo heart│{7: }// Frobs foo hear|
  433. {7: }int frobnitz(int f│{7: }int frobnitz(int |
  434. {7: }{ │{7: }{ |
  435. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  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. end)
  459. describe('diffopt+=indent-heuristic', function()
  460. setup(function()
  461. local f1 = [[
  462. def finalize(values)
  463. values.each do |v|
  464. v.finalize
  465. end]]
  466. write_file(fname, f1, false)
  467. local f2 = [[
  468. def finalize(values)
  469. values.each do |v|
  470. v.prepare
  471. end
  472. values.each do |v|
  473. v.finalize
  474. end]]
  475. write_file(fname_2, f2, false)
  476. feed(':diffupdate!<cr>')
  477. end)
  478. it('internal', function()
  479. reread()
  480. feed(':set diffopt=internal,filler<cr>')
  481. screen:expect([[
  482. {7: }^def finalize(value│{7: }def finalize(valu|
  483. {7: } │{7: } |
  484. {7: } values.each do |│{7: } values.each do |
  485. {7: }{23:------------------}│{7: }{22: v.prepare }|
  486. {7: }{23:------------------}│{7: }{22: end }|
  487. {7: }{23:------------------}│{7: }{22: }|
  488. {7: }{23:------------------}│{7: }{22: values.each do }|
  489. {7: } v.finalize │{7: } v.finalize |
  490. {7: } end │{7: } end |
  491. {1:~ }│{1:~ }|*5
  492. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  493. :set diffopt=internal,filler |
  494. ]])
  495. end)
  496. it('indent-heuristic', function()
  497. reread()
  498. feed(':set diffopt=internal,filler,indent-heuristic<cr>')
  499. screen:expect([[
  500. {7: }^def finalize(value│{7: }def finalize(valu|
  501. {7: } │{7: } |
  502. {7: }{23:------------------}│{7: }{22: values.each do }|
  503. {7: }{23:------------------}│{7: }{22: v.prepare }|
  504. {7: }{23:------------------}│{7: }{22: end }|
  505. {7: }{23:------------------}│{7: }{22: }|
  506. {7: } values.each do |│{7: } values.each do |
  507. {7: } v.finalize │{7: } v.finalize |
  508. {7: } end │{7: } end |
  509. {1:~ }│{1:~ }|*5
  510. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  511. |
  512. ]])
  513. end)
  514. it('indent-heuristic random order', function()
  515. reread()
  516. feed(':set diffopt=internal,filler,indent-heuristic,algorithm:patience<cr>')
  517. feed(':<cr>')
  518. screen:expect([[
  519. {7: }^def finalize(value│{7: }def finalize(valu|
  520. {7: } │{7: } |
  521. {7: }{23:------------------}│{7: }{22: values.each do }|
  522. {7: }{23:------------------}│{7: }{22: v.prepare }|
  523. {7: }{23:------------------}│{7: }{22: end }|
  524. {7: }{23:------------------}│{7: }{22: }|
  525. {7: } values.each do |│{7: } values.each do |
  526. {7: } v.finalize │{7: } v.finalize |
  527. {7: } end │{7: } end |
  528. {1:~ }│{1:~ }|*5
  529. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  530. : |
  531. ]])
  532. end)
  533. end)
  534. it('Diff the same file', function()
  535. write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  536. write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false)
  537. reread()
  538. feed(':set diffopt=filler<cr>')
  539. screen:expect([[
  540. {7:+ }{13:^+-- 10 lines: 1···}│{7:+ }{13:+-- 10 lines: 1··}|
  541. {1:~ }│{1:~ }|*13
  542. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  543. :set diffopt=filler |
  544. ]])
  545. feed(':set diffopt+=internal<cr>')
  546. screen:expect([[
  547. {7:+ }{13:^+-- 10 lines: 1···}│{7:+ }{13:+-- 10 lines: 1··}|
  548. {1:~ }│{1:~ }|*13
  549. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  550. :set diffopt+=internal |
  551. ]])
  552. end)
  553. it('Diff an empty file', function()
  554. write_file(fname, '', false)
  555. write_file(fname_2, '', false)
  556. reread()
  557. feed(':set diffopt=filler<cr>')
  558. screen:expect([[
  559. {7:- }^ │{7:- } |
  560. {1:~ }│{1:~ }|*13
  561. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  562. :set diffopt=filler |
  563. ]])
  564. feed(':set diffopt+=internal<cr>')
  565. screen:expect([[
  566. {7:- }^ │{7:- } |
  567. {1:~ }│{1:~ }|*13
  568. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  569. :set diffopt+=internal |
  570. ]])
  571. end)
  572. it('Diff empty and non-empty file', function()
  573. write_file(fname, '', false)
  574. write_file(fname_2, 'foo\nbar\nbaz', false)
  575. reread()
  576. feed(':set diffopt=filler<cr>')
  577. screen:expect([[
  578. {7: }{23:------------------}│{7: }{22:foo }|
  579. {7: }{23:------------------}│{7: }{22:bar }|
  580. {7: }{23:------------------}│{7: }{22:baz }|
  581. {7: }^ │{1:~ }|
  582. {1:~ }│{1:~ }|*10
  583. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  584. :set diffopt=filler |
  585. ]])
  586. feed(':set diffopt+=internal<cr>')
  587. screen:expect([[
  588. {7: }{23:------------------}│{7: }{22:foo }|
  589. {7: }{23:------------------}│{7: }{22:bar }|
  590. {7: }{23:------------------}│{7: }{22:baz }|
  591. {7: }^ │{1:~ }|
  592. {1:~ }│{1:~ }|*10
  593. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  594. :set diffopt+=internal |
  595. ]])
  596. end)
  597. it('diffopt+=icase', function()
  598. write_file(fname, 'a\nb\ncd\n', false)
  599. write_file(fname_2, 'A\nb\ncDe\n', false)
  600. reread()
  601. feed(':set diffopt=filler,icase<cr>')
  602. screen:expect([[
  603. {7: }^a │{7: }A |
  604. {7: }b │{7: }b |
  605. {7: }{4:cd }│{7: }{4:cD}{27:e}{4: }|
  606. {1:~ }│{1:~ }|*11
  607. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  608. :set diffopt=filler,icase |
  609. ]])
  610. feed(':set diffopt+=internal<cr>')
  611. screen:expect([[
  612. {7: }^a │{7: }A |
  613. {7: }b │{7: }b |
  614. {7: }{4:cd }│{7: }{4:cD}{27:e}{4: }|
  615. {1:~ }│{1:~ }|*11
  616. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  617. :set diffopt+=internal |
  618. ]])
  619. end)
  620. describe('diffopt+=iwhite', function()
  621. setup(function()
  622. local f1 = 'int main()\n{\n printf("Hello, World!");\n return 0;\n}\n'
  623. write_file(fname, f1, false)
  624. local f2 =
  625. 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n'
  626. write_file(fname_2, f2, false)
  627. feed(':diffupdate!<cr>')
  628. end)
  629. it('external', function()
  630. reread()
  631. feed(':set diffopt=filler,iwhite<cr>')
  632. screen:expect([[
  633. {7: }^int main() │{7: }int main() |
  634. {7: }{ │{7: }{ |
  635. {7: }{23:------------------}│{7: }{22: if (0) }|
  636. {7: }{23:------------------}│{7: }{22: { }|
  637. {7: } printf("Hello, │{7: } printf("Hel|
  638. {7: } return 0; │{7: } return 0; |
  639. {7: }{23:------------------}│{7: }{22: } }|
  640. {7: }} │{7: }} |
  641. {1:~ }│{1:~ }|*6
  642. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  643. :set diffopt=filler,iwhite |
  644. ]])
  645. end)
  646. it('internal', function()
  647. reread()
  648. feed(':set diffopt=filler,iwhite,internal<cr>')
  649. screen:expect([[
  650. {7: }^int main() │{7: }int main() |
  651. {7: }{ │{7: }{ |
  652. {7: }{23:------------------}│{7: }{22: if (0) }|
  653. {7: }{23:------------------}│{7: }{22: { }|
  654. {7: } printf("Hello, │{7: } printf("Hel|
  655. {7: } return 0; │{7: } return 0; |
  656. {7: }{23:------------------}│{7: }{22: } }|
  657. {7: }} │{7: }} |
  658. {1:~ }│{1:~ }|*6
  659. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  660. :set diffopt=filler,iwhite,internal |
  661. ]])
  662. end)
  663. end)
  664. describe('diffopt+=iblank', function()
  665. setup(function()
  666. write_file(fname, 'a\n\n \ncd\nef\nxxx\n', false)
  667. write_file(fname_2, 'a\ncd\n\nef\nyyy\n', false)
  668. feed(':diffupdate!<cr>')
  669. end)
  670. it('generic', function()
  671. reread()
  672. feed(':set diffopt=internal,filler,iblank<cr>')
  673. screen:expect([[
  674. {7: }^a │{7: }a |
  675. {7: }{22: }│{7: }{23:-----------------}|*2
  676. {7: }cd │{7: }cd |
  677. {7: }ef │{7: } |
  678. {7: }{27:xxx}{4: }│{7: }ef |
  679. {1:~ }│{7: }{27:yyy}{4: }|
  680. {1:~ }│{1:~ }|*7
  681. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  682. :set diffopt=internal,filler,iblank |
  683. ]])
  684. end)
  685. it('diffopt+=iwhite', function()
  686. reread()
  687. feed(':set diffopt=internal,filler,iblank,iwhite<cr>')
  688. feed(':<cr>')
  689. screen:expect([[
  690. {7: }^a │{7: }a |
  691. {7: } │{7: }cd |
  692. {7: } │{7: } |
  693. {7: }cd │{7: }ef |
  694. {7: }ef │{7: }{27:yyy}{4: }|
  695. {7: }{27:xxx}{4: }│{1:~ }|
  696. {1:~ }│{1:~ }|*8
  697. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  698. : |
  699. ]])
  700. end)
  701. it('diffopt+=iwhiteall', function()
  702. reread()
  703. feed(':set diffopt=internal,filler,iblank,iwhiteall<cr>')
  704. feed(':<cr>')
  705. screen:expect([[
  706. {7: }^a │{7: }a |
  707. {7: } │{7: }cd |
  708. {7: } │{7: } |
  709. {7: }cd │{7: }ef |
  710. {7: }ef │{7: }{27:yyy}{4: }|
  711. {7: }{27:xxx}{4: }│{1:~ }|
  712. {1:~ }│{1:~ }|*8
  713. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  714. : |
  715. ]])
  716. end)
  717. it('diffopt+=iwhiteeol', function()
  718. reread()
  719. feed(':set diffopt=internal,filler,iblank,iwhiteeol<cr>')
  720. feed(':<cr>')
  721. screen:expect([[
  722. {7: }^a │{7: }a |
  723. {7: } │{7: }cd |
  724. {7: } │{7: } |
  725. {7: }cd │{7: }ef |
  726. {7: }ef │{7: }{27:yyy}{4: }|
  727. {7: }{27:xxx}{4: }│{1:~ }|
  728. {1:~ }│{1:~ }|*8
  729. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  730. : |
  731. ]])
  732. end)
  733. end)
  734. describe('diffopt+=iwhite{eol,all}', function()
  735. setup(function()
  736. write_file(fname, 'a \nx\ncd\nef\nxx xx\nfoo\nbar\n', false)
  737. write_file(fname_2, 'a\nx\nc d\n ef\nxx xx\nfoo\n\nbar\n', false)
  738. feed(':diffupdate!<cr>')
  739. end)
  740. it('diffopt+=iwhiteeol', function()
  741. reread()
  742. feed(':set diffopt=internal,filler,iwhiteeol<cr>')
  743. feed(':<cr>')
  744. screen:expect([[
  745. {7: }^a │{7: }a |
  746. {7: }x │{7: }x |
  747. {7: }{4:cd }│{7: }{4:c}{27: }{4:d }|
  748. {7: }{4:ef }│{7: }{27: }{4:ef }|
  749. {7: }{4:xx }{27: }{4:xx }│{7: }{4:xx xx }|
  750. {7: }foo │{7: }foo |
  751. {7: }{23:------------------}│{7: }{22: }|
  752. {7: }bar │{7: }bar |
  753. {1:~ }│{1:~ }|*6
  754. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  755. : |
  756. ]])
  757. end)
  758. it('diffopt+=iwhiteall', function()
  759. reread()
  760. feed(':set diffopt=internal,filler,iwhiteall<cr>')
  761. feed(':<cr>')
  762. screen:expect([[
  763. {7: }^a │{7: }a |
  764. {7: }x │{7: }x |
  765. {7: }cd │{7: }c d |
  766. {7: }ef │{7: } ef |
  767. {7: }xx xx │{7: }xx xx |
  768. {7: }foo │{7: }foo |
  769. {7: }{23:------------------}│{7: }{22: }|
  770. {7: }bar │{7: }bar |
  771. {1:~ }│{1:~ }|*6
  772. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  773. : |
  774. ]])
  775. end)
  776. end)
  777. -- oldtest: Test_diff_scroll()
  778. -- This was scrolling for 'cursorbind' but 'scrollbind' is more important
  779. it('scrolling works correctly vim-patch:8.2.5155', function()
  780. screen:try_resize(40, 12)
  781. write_file(
  782. fname,
  783. dedent([[
  784. line 1
  785. line 2
  786. line 3
  787. line 4
  788. // Common block
  789. // one
  790. // containing
  791. // four lines
  792. // Common block
  793. // two
  794. // containing
  795. // four lines]]),
  796. false
  797. )
  798. write_file(
  799. fname_2,
  800. dedent([[
  801. line 1
  802. line 2
  803. line 3
  804. line 4
  805. Lorem
  806. ipsum
  807. dolor
  808. sit
  809. amet,
  810. consectetur
  811. adipiscing
  812. elit.
  813. Etiam
  814. luctus
  815. lectus
  816. sodales,
  817. dictum
  818. // Common block
  819. // one
  820. // containing
  821. // four lines
  822. Vestibulum
  823. tincidunt
  824. aliquet
  825. nulla.
  826. // Common block
  827. // two
  828. // containing
  829. // four lines]]),
  830. false
  831. )
  832. reread()
  833. feed('<C-W><C-W>jjjj')
  834. screen:expect([[
  835. {7: }line 1 │{7: }line 1 |
  836. {7: }line 2 │{7: }line 2 |
  837. {7: }line 3 │{7: }line 3 |
  838. {7: }line 4 │{7: }line 4 |
  839. {7: } │{7: }^ |
  840. {7: }{23:-----------------}│{7: }{22:Lorem }|
  841. {7: }{23:-----------------}│{7: }{22:ipsum }|
  842. {7: }{23:-----------------}│{7: }{22:dolor }|
  843. {7: }{23:-----------------}│{7: }{22:sit }|
  844. {7: }{23:-----------------}│{7: }{22:amet, }|
  845. {2:<nal-diff-screen-1 }{3:<al-diff-screen-1.2 }|
  846. :e |
  847. ]])
  848. feed('j')
  849. screen:expect([[
  850. {7: }line 1 │{7: }line 1 |
  851. {7: }line 2 │{7: }line 2 |
  852. {7: }line 3 │{7: }line 3 |
  853. {7: }line 4 │{7: }line 4 |
  854. {7: } │{7: } |
  855. {7: }{23:-----------------}│{7: }{22:^Lorem }|
  856. {7: }{23:-----------------}│{7: }{22:ipsum }|
  857. {7: }{23:-----------------}│{7: }{22:dolor }|
  858. {7: }{23:-----------------}│{7: }{22:sit }|
  859. {7: }{23:-----------------}│{7: }{22:amet, }|
  860. {2:<nal-diff-screen-1 }{3:<al-diff-screen-1.2 }|
  861. :e |
  862. ]])
  863. end)
  864. describe('line matching diff algorithm', function()
  865. setup(function()
  866. local f1 = [[if __name__ == "__main__":
  867. import sys
  868. app = QWidgets.QApplication(sys.args)
  869. MainWindow = QtWidgets.QMainWindow()
  870. ui = UI_MainWindow()
  871. ui.setupUI(MainWindow)
  872. MainWindow.show()
  873. sys.exit(app.exec_())]]
  874. write_file(fname, f1, false)
  875. local f2 = [[if __name__ == "__main__":
  876. import sys
  877. comment these things
  878. #app = QWidgets.QApplication(sys.args)
  879. #MainWindow = QtWidgets.QMainWindow()
  880. add a completely different line here
  881. #ui = UI_MainWindow()
  882. add another new line
  883. ui.setupUI(MainWindow)
  884. MainWindow.show()
  885. sys.exit(app.exec_())]]
  886. write_file(fname_2, f2, false)
  887. end)
  888. it('diffopt+=linematch:20', function()
  889. reread()
  890. feed(':set diffopt=internal,filler<cr>')
  891. screen:expect([[
  892. {7: }^if __name__ == "__│{7: }if __name__ == "_|
  893. {7: } import sys │{7: } import sys |
  894. {7: }{4: }{27:app = QWidgets}│{7: }{4: }{27:comment these}|
  895. {7: }{4: }{27:MainWindow = Q}│{7: }{4: }{27:#app = QWidge}|
  896. {7: }{4: }{27:ui = UI_}{4:MainWi}│{7: }{4: }{27:#MainWindow =}|
  897. {7: }{23:------------------}│{7: }{22: add a complet}|
  898. {7: }{23:------------------}│{7: }{22: #ui = UI_Main}|
  899. {7: }{23:------------------}│{7: }{22: add another n}|
  900. {7: } ui.setupUI(Mai│{7: } ui.setupUI(Ma|
  901. {7: } MainWindow.sho│{7: } MainWindow.sh|
  902. {7: } sys.exit(app.e│{7: } sys.exit(app.|
  903. {1:~ }│{1:~ }|*3
  904. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  905. :set diffopt=internal,filler |
  906. ]])
  907. feed('G')
  908. feed(':set diffopt+=linematch:20<cr>')
  909. screen:expect([[
  910. {7: }if __name__ == "__│{7: }if __name__ == "_|
  911. {7: } import sys │{7: } import sys |
  912. {7: }{23:------------------}│{7: }{22: comment these}|
  913. {7: }{4: app = QWidgets}│{7: }{4: }{27:#}{4:app = QWidge}|
  914. {7: }{4: MainWindow = Q}│{7: }{4: }{27:#}{4:MainWindow =}|
  915. {7: }{23:------------------}│{7: }{22: add a complet}|
  916. {7: }{4: ui = UI_MainWi}│{7: }{4: }{27:#}{4:ui = UI_Main}|
  917. {7: }{23:------------------}│{7: }{22: add another n}|
  918. {7: } ui.setupUI(Mai│{7: } ui.setupUI(Ma|
  919. {7: } MainWindow.sho│{7: } MainWindow.sh|
  920. {7: } ^sys.exit(app.e│{7: } sys.exit(app.|
  921. {1:~ }│{1:~ }|*3
  922. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  923. :set diffopt+=linematch:20 |
  924. ]])
  925. end)
  926. end)
  927. describe('line matching diff algorithm with icase', function()
  928. setup(function()
  929. local f1 = [[DDD
  930. _aa]]
  931. write_file(fname, f1, false)
  932. local f2 = [[DDD
  933. AAA
  934. ccca]]
  935. write_file(fname_2, f2, false)
  936. end)
  937. it('diffopt+=linematch:20,icase', function()
  938. reread()
  939. feed(':set diffopt=internal,filler,linematch:20<cr>')
  940. screen:expect([[
  941. {7: }^DDD │{7: }DDD |
  942. {7: }{23:------------------}│{7: }{22:AAA }|
  943. {7: }{27:_a}{4:a }│{7: }{27:ccc}{4:a }|
  944. {1:~ }│{1:~ }|*11
  945. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  946. |
  947. ]])
  948. feed(':set diffopt+=icase<cr>')
  949. screen:expect([[
  950. {7: }^DDD │{7: }DDD |
  951. {7: }{27:_}{4:aa }│{7: }{27:A}{4:AA }|
  952. {7: }{23:------------------}│{7: }{22:ccca }|
  953. {1:~ }│{1:~ }|*11
  954. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  955. :set diffopt+=icase |
  956. ]])
  957. end)
  958. end)
  959. describe('line matching diff algorithm with iwhiteall', function()
  960. setup(function()
  961. local f1 = [[BB
  962. AAA]]
  963. write_file(fname, f1, false)
  964. local f2 = [[BB
  965. AAB
  966. AAAB]]
  967. write_file(fname_2, f2, false)
  968. end)
  969. it('diffopt+=linematch:20,iwhiteall', function()
  970. reread()
  971. feed(':set diffopt=internal,filler,linematch:20<cr>')
  972. screen:expect {
  973. grid = [[
  974. {7: }^BB │{7: }BB |
  975. {7: }{4: AA}{27:A}{4: }│{7: }{4: AA}{27:B}{4: }|
  976. {7: }{23:------------------}│{7: }{22:AAAB }|
  977. {1:~ }│{1:~ }|*11
  978. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  979. |
  980. ]],
  981. }
  982. feed(':set diffopt+=iwhiteall<cr>')
  983. screen:expect {
  984. grid = [[
  985. {7: }^BB │{7: }BB |
  986. {7: }{23:------------------}│{7: }{22: AAB }|
  987. {7: }{4: AAA }│{7: }{4:AAA}{27:B}{4: }|
  988. {1:~ }│{1:~ }|*11
  989. {3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
  990. :set diffopt+=iwhiteall |
  991. ]],
  992. }
  993. end)
  994. end)
  995. it('redraws with a change to non-current buffer', function()
  996. write_file(fname, 'aaa\nbbb\nccc\n\nxx', false)
  997. write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false)
  998. reread()
  999. local buf = api.nvim_get_current_buf()
  1000. command('botright new')
  1001. screen:expect {
  1002. grid = [[
  1003. {7: }aaa │{7: }aaa |
  1004. {7: }bbb │{7: }bbb |
  1005. {7: }ccc │{7: }ccc |
  1006. {7: } │{7: } |
  1007. {7: }{27:xx}{4: }│{7: }{27:yy}{4: }|
  1008. {1:~ }│{1:~ }|
  1009. {2:<onal-diff-screen-1 <l-diff-screen-1.2 }|
  1010. ^ |
  1011. {1:~ }|*6
  1012. {3:[No Name] }|
  1013. :e |
  1014. ]],
  1015. }
  1016. api.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' })
  1017. screen:expect {
  1018. grid = [[
  1019. {7: }aaa │{7: }aaa |
  1020. {7: }{27:BBB}{4: }│{7: }{27:bbb}{4: }|
  1021. {7: }ccc │{7: }ccc |
  1022. {7: } │{7: } |
  1023. {7: }{27:xx}{4: }│{7: }{27:yy}{4: }|
  1024. {1:~ }│{1:~ }|
  1025. {2:<-diff-screen-1 [+] <l-diff-screen-1.2 }|
  1026. ^ |
  1027. {1:~ }|*6
  1028. {3:[No Name] }|
  1029. :e |
  1030. ]],
  1031. }
  1032. end)
  1033. it('redraws with a change current buffer in another window', function()
  1034. write_file(fname, 'aaa\nbbb\nccc\n\nxx', false)
  1035. write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false)
  1036. reread()
  1037. local buf = api.nvim_get_current_buf()
  1038. command('botright split | diffoff')
  1039. screen:expect {
  1040. grid = [[
  1041. {7: }aaa │{7: }aaa |
  1042. {7: }bbb │{7: }bbb |
  1043. {7: }ccc │{7: }ccc |
  1044. {7: } │{7: } |
  1045. {7: }{27:xx}{4: }│{7: }{27:yy}{4: }|
  1046. {1:~ }│{1:~ }|
  1047. {2:<onal-diff-screen-1 <l-diff-screen-1.2 }|
  1048. ^aaa |
  1049. bbb |
  1050. ccc |
  1051. |
  1052. xx |
  1053. {1:~ }|*2
  1054. {3:Xtest-functional-diff-screen-1 }|
  1055. :e |
  1056. ]],
  1057. }
  1058. api.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' })
  1059. screen:expect {
  1060. grid = [[
  1061. {7: }aaa │{7: }aaa |
  1062. {7: }{27:BBB}{4: }│{7: }{27:bbb}{4: }|
  1063. {7: }ccc │{7: }ccc |
  1064. {7: } │{7: } |
  1065. {7: }{27:xx}{4: }│{7: }{27:yy}{4: }|
  1066. {1:~ }│{1:~ }|
  1067. {2:<-diff-screen-1 [+] <l-diff-screen-1.2 }|
  1068. ^aaa |
  1069. BBB |
  1070. ccc |
  1071. |
  1072. xx |
  1073. {1:~ }|*2
  1074. {3:Xtest-functional-diff-screen-1 [+] }|
  1075. :e |
  1076. ]],
  1077. }
  1078. end)
  1079. end)
  1080. it('win_update redraws lines properly', function()
  1081. local screen
  1082. screen = Screen.new(50, 10)
  1083. screen:set_default_attr_ids({
  1084. [1] = { bold = true, foreground = Screen.colors.Blue1 },
  1085. [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
  1086. [3] = {
  1087. background = Screen.colors.Red,
  1088. foreground = Screen.colors.Grey100,
  1089. special = Screen.colors.Yellow,
  1090. },
  1091. [4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
  1092. [5] = { special = Screen.colors.Yellow },
  1093. [6] = { special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4 },
  1094. [7] = { foreground = Screen.colors.Grey0, background = Screen.colors.Grey100 },
  1095. [8] = { foreground = Screen.colors.Gray90, background = Screen.colors.Grey100 },
  1096. [9] = { foreground = tonumber('0x00000c'), background = Screen.colors.Grey100 },
  1097. [10] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff') },
  1098. [11] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452') },
  1099. [12] = { bold = true, reverse = true },
  1100. [13] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray },
  1101. [14] = { reverse = true },
  1102. [15] = { background = Screen.colors.LightBlue },
  1103. [16] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 },
  1104. [17] = { bold = true, background = Screen.colors.Red },
  1105. [18] = { background = Screen.colors.LightMagenta },
  1106. })
  1107. insert([[
  1108. 1
  1109. 2
  1110. 1a
  1111. ]])
  1112. command('vnew left')
  1113. insert([[
  1114. 2
  1115. 2a
  1116. 2b
  1117. ]])
  1118. command('windo diffthis')
  1119. command('windo 1')
  1120. screen:expect {
  1121. grid = [[
  1122. {13: }{16:-----------------------}│{13: }{15:^1 }|
  1123. {13: }{16:-----------------------}│{13: }{15: }|*2
  1124. {13: }2 │{13: }2 |
  1125. {13: }{17:2}{18:a }│{13: }{17:1}{18:a }|
  1126. {13: }{15:2b }│{13: }{16:----------------------}|
  1127. {13: } │{13: } |
  1128. {1:~ }│{1:~ }|
  1129. {14:left [+] }{12:[No Name] [+] }|
  1130. |
  1131. ]],
  1132. }
  1133. feed('<C-e>')
  1134. feed('<C-e>')
  1135. feed('<C-y>')
  1136. feed('<C-y>')
  1137. feed('<C-y>')
  1138. screen:expect {
  1139. grid = [[
  1140. {13: }{16:-----------------------}│{13: }{15:1 }|
  1141. {13: }{16:-----------------------}│{13: }{15: }|
  1142. {13: }{16:-----------------------}│{13: }{15:^ }|
  1143. {13: }2 │{13: }2 |
  1144. {13: }{17:2}{18:a }│{13: }{17:1}{18:a }|
  1145. {13: }{15:2b }│{13: }{16:----------------------}|
  1146. {13: } │{13: } |
  1147. {1:~ }│{1:~ }|
  1148. {14:left [+] }{12:[No Name] [+] }|
  1149. |
  1150. ]],
  1151. }
  1152. end)
  1153. -- oldtest: Test_diff_rnu()
  1154. it('diff updates line numbers below filler lines', function()
  1155. local screen = Screen.new(40, 14)
  1156. exec([[
  1157. call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
  1158. vnew
  1159. call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
  1160. windo diffthis
  1161. setlocal number rnu cursorline cursorlineopt=number foldcolumn=0
  1162. ]])
  1163. screen:expect([[
  1164. {7: }a │{15:1 }^a |
  1165. {7: }a │{8: 1 }a |
  1166. {7: }a │{8: 2 }a |
  1167. {7: }{27:x}{4: }│{8: 3 }{27:y}{4: }|
  1168. {7: }{22:x }│{8: }{23:----------------}|*2
  1169. {7: }b │{8: 4 }b |
  1170. {7: }b │{8: 5 }b |
  1171. {7: }b │{8: 6 }b |
  1172. {7: }b │{8: 7 }b |
  1173. {7: }b │{8: 8 }b |
  1174. {1:~ }│{1:~ }|
  1175. {2:[No Name] [+] }{3:[No Name] [+] }|
  1176. |
  1177. ]])
  1178. feed('j')
  1179. screen:expect([[
  1180. {7: }a │{8: 1 }a |
  1181. {7: }a │{15:2 }^a |
  1182. {7: }a │{8: 1 }a |
  1183. {7: }{27:x}{4: }│{8: 2 }{27:y}{4: }|
  1184. {7: }{22:x }│{8: }{23:----------------}|*2
  1185. {7: }b │{8: 3 }b |
  1186. {7: }b │{8: 4 }b |
  1187. {7: }b │{8: 5 }b |
  1188. {7: }b │{8: 6 }b |
  1189. {7: }b │{8: 7 }b |
  1190. {1:~ }│{1:~ }|
  1191. {2:[No Name] [+] }{3:[No Name] [+] }|
  1192. |
  1193. ]])
  1194. feed('j')
  1195. screen:expect([[
  1196. {7: }a │{8: 2 }a |
  1197. {7: }a │{8: 1 }a |
  1198. {7: }a │{15:3 }^a |
  1199. {7: }{27:x}{4: }│{8: 1 }{27:y}{4: }|
  1200. {7: }{22:x }│{8: }{23:----------------}|*2
  1201. {7: }b │{8: 2 }b |
  1202. {7: }b │{8: 3 }b |
  1203. {7: }b │{8: 4 }b |
  1204. {7: }b │{8: 5 }b |
  1205. {7: }b │{8: 6 }b |
  1206. {1:~ }│{1:~ }|
  1207. {2:[No Name] [+] }{3:[No Name] [+] }|
  1208. |
  1209. ]])
  1210. end)
  1211. -- oldtest: Test_diff_with_scroll_and_change()
  1212. it('Align the filler lines when changing text in diff mode', function()
  1213. local screen = Screen.new(40, 20)
  1214. exec([[
  1215. call setline(1, range(1, 15))
  1216. vnew
  1217. call setline(1, range(9, 15))
  1218. windo diffthis
  1219. wincmd h
  1220. exe "normal Gl5\<C-E>"
  1221. ]])
  1222. screen:expect {
  1223. grid = [[
  1224. {7: }{23:------------------}│{7: }{22:6 }|
  1225. {7: }{23:------------------}│{7: }{22:7 }|
  1226. {7: }{23:------------------}│{7: }{22:8 }|
  1227. {7: }9 │{7: }9 |
  1228. {7: }10 │{7: }10 |
  1229. {7: }11 │{7: }11 |
  1230. {7: }12 │{7: }12 |
  1231. {7: }13 │{7: }13 |
  1232. {7: }14 │{7: }14 |
  1233. {7:- }1^5 │{7:- }15 |
  1234. {1:~ }│{1:~ }|*8
  1235. {3:[No Name] [+] }{2:[No Name] [+] }|
  1236. |
  1237. ]],
  1238. }
  1239. feed('ax<Esc>')
  1240. screen:expect {
  1241. grid = [[
  1242. {7: }{23:------------------}│{7: }{22:6 }|
  1243. {7: }{23:------------------}│{7: }{22:7 }|
  1244. {7: }{23:------------------}│{7: }{22:8 }|
  1245. {7: }9 │{7: }9 |
  1246. {7: }10 │{7: }10 |
  1247. {7: }11 │{7: }11 |
  1248. {7: }12 │{7: }12 |
  1249. {7: }13 │{7: }13 |
  1250. {7: }14 │{7: }14 |
  1251. {7: }{4:15}{27:^x}{4: }│{7: }{4:15 }|
  1252. {1:~ }│{1:~ }|*8
  1253. {3:[No Name] [+] }{2:[No Name] [+] }|
  1254. |
  1255. ]],
  1256. }
  1257. feed('<C-W>lay<Esc>')
  1258. screen:expect {
  1259. grid = [[
  1260. {7: }{23:-----------------}│{7: }{22:6 }|
  1261. {7: }{23:-----------------}│{7: }{22:7 }|
  1262. {7: }{23:-----------------}│{7: }{22:8 }|
  1263. {7: }9 │{7: }9 |
  1264. {7: }10 │{7: }10 |
  1265. {7: }11 │{7: }11 |
  1266. {7: }12 │{7: }12 |
  1267. {7: }13 │{7: }13 |
  1268. {7: }14 │{7: }14 |
  1269. {7: }{4:15}{27:x}{4: }│{7: }{4:15}{27:^y}{4: }|
  1270. {1:~ }│{1:~ }|*8
  1271. {2:[No Name] [+] }{3:[No Name] [+] }|
  1272. |
  1273. ]],
  1274. }
  1275. end)
  1276. it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function()
  1277. local screen = Screen.new(60, 6)
  1278. eq('0', api.nvim_get_option_value('foldcolumn', {}))
  1279. command('diffsplit | bd')
  1280. screen:expect([[
  1281. ^ |
  1282. {1:~ }|*4
  1283. |
  1284. ]])
  1285. eq('0', api.nvim_get_option_value('foldcolumn', {}))
  1286. end)
  1287. it("'relativenumber' doesn't draw beyond end of window in diff mode #29403", function()
  1288. local screen = Screen.new(60, 12)
  1289. command('set relativenumber')
  1290. feed('10aa<CR><Esc>gg')
  1291. command('vnew')
  1292. feed('ab<CR><Esc>gg')
  1293. command('windo diffthis')
  1294. command('wincmd |')
  1295. screen:expect([[
  1296. {8: }│{7: }{8: 0 }{27:^a}{4: }|
  1297. {8: }│{7: }{8: 1 }{22:a }|
  1298. {8: }│{7: }{8: 2 }{22:a }|
  1299. {8: }│{7: }{8: 3 }{22:a }|
  1300. {8: }│{7: }{8: 4 }{22:a }|
  1301. {8: }│{7: }{8: 5 }{22:a }|
  1302. {8: }│{7: }{8: 6 }{22:a }|
  1303. {8: }│{7: }{8: 7 }{22:a }|
  1304. {8: }│{7: }{8: 8 }{22:a }|
  1305. {8: }│{7: }{8: 9 }{22:a }|
  1306. {2:< }{3:[No Name] [+] }|
  1307. |
  1308. ]])
  1309. feed('j')
  1310. screen:expect([[
  1311. {8: }│{7: }{8: 1 }{27:a}{4: }|
  1312. {8: }│{7: }{8: 0 }{22:^a }|
  1313. {8: }│{7: }{8: 1 }{22:a }|
  1314. {8: }│{7: }{8: 2 }{22:a }|
  1315. {8: }│{7: }{8: 3 }{22:a }|
  1316. {8: }│{7: }{8: 4 }{22:a }|
  1317. {8: }│{7: }{8: 5 }{22:a }|
  1318. {8: }│{7: }{8: 6 }{22:a }|
  1319. {8: }│{7: }{8: 7 }{22:a }|
  1320. {8: }│{7: }{8: 8 }{22:a }|
  1321. {2:< }{3:[No Name] [+] }|
  1322. |
  1323. ]])
  1324. end)
  1325. -- oldtest: Test_diff_binary()
  1326. it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
  1327. local screen = Screen.new(40, 20)
  1328. screen:add_extra_attr_ids {
  1329. [100] = { foreground = Screen.colors.Blue, bold = true, background = Screen.colors.Red },
  1330. }
  1331. exec([[
  1332. call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g'])
  1333. vnew
  1334. call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g'])
  1335. windo diffthis
  1336. wincmd p
  1337. norm! gg0
  1338. redraw!
  1339. ]])
  1340. -- Test using internal diff
  1341. screen:expect([[
  1342. {7: }{27:^A}{4: }│{7: }{27:a}{4: }|
  1343. {7: }b │{7: }b |
  1344. {7: }{4:c }│{7: }{4:c}{100:^@}{4: }|
  1345. {7: }d │{7: }d |
  1346. {7: }{27:E}{4: }│{7: }{27:e}{4: }|
  1347. {7: }f │{7: }f |
  1348. {7: }g │{7: }g |
  1349. {1:~ }│{1:~ }|*11
  1350. {3:[No Name] [+] }{2:[No Name] [+] }|
  1351. |
  1352. ]])
  1353. -- Test using internal diff and case folding
  1354. command('set diffopt+=icase')
  1355. feed('<C-L>')
  1356. screen:expect([[
  1357. {7: }^A │{7: }a |
  1358. {7: }b │{7: }b |
  1359. {7: }{4:c }│{7: }{4:c}{100:^@}{4: }|
  1360. {7: }d │{7: }d |
  1361. {7: }E │{7: }e |
  1362. {7: }f │{7: }f |
  1363. {7: }g │{7: }g |
  1364. {1:~ }│{1:~ }|*11
  1365. {3:[No Name] [+] }{2:[No Name] [+] }|
  1366. |
  1367. ]])
  1368. -- Test using external diff
  1369. command('set diffopt=filler')
  1370. feed('<C-L>')
  1371. screen:expect([[
  1372. {7: }{27:^A}{4: }│{7: }{27:a}{4: }|
  1373. {7: }b │{7: }b |
  1374. {7: }{4:c }│{7: }{4:c}{100:^@}{4: }|
  1375. {7: }d │{7: }d |
  1376. {7: }{27:E}{4: }│{7: }{27:e}{4: }|
  1377. {7: }f │{7: }f |
  1378. {7: }g │{7: }g |
  1379. {1:~ }│{1:~ }|*11
  1380. {3:[No Name] [+] }{2:[No Name] [+] }|
  1381. |
  1382. ]])
  1383. -- Test using external diff and case folding
  1384. command('set diffopt+=filler,icase')
  1385. feed('<C-L>')
  1386. screen:expect([[
  1387. {7: }^A │{7: }a |
  1388. {7: }b │{7: }b |
  1389. {7: }{4:c }│{7: }{4:c}{100:^@}{4: }|
  1390. {7: }d │{7: }d |
  1391. {7: }E │{7: }e |
  1392. {7: }f │{7: }f |
  1393. {7: }g │{7: }g |
  1394. {1:~ }│{1:~ }|*11
  1395. {3:[No Name] [+] }{2:[No Name] [+] }|
  1396. |
  1397. ]])
  1398. end)
  1399. -- oldtest: Test_diff_breakindent_after_filler()
  1400. it("diff mode draws 'breakindent' correctly after filler lines", function()
  1401. local screen = Screen.new(45, 8)
  1402. exec([[
  1403. set laststatus=0 diffopt+=followwrap breakindent breakindentopt=min:0
  1404. call setline(1, ['a', ' ' .. repeat('c', 50)])
  1405. vnew
  1406. call setline(1, ['a', 'b', ' ' .. repeat('c', 50)])
  1407. windo diffthis
  1408. norm! G$
  1409. ]])
  1410. screen:expect([[
  1411. {7: }a │{7: }a |
  1412. {7: }{22:b }│{7: }{23:--------------------}|
  1413. {7: } cccccccccccccccccc│{7: } cccccccccccccccccc|*2
  1414. {7: } cccccccccccccc │{7: } ccccccccccccc^c |
  1415. {1:~ }│{1:~ }|*2
  1416. |
  1417. ]])
  1418. end)
  1419. -- oldtest: Test_diff_overlapped_diff_blocks_will_be_merged()
  1420. it('diff mode overlapped diff blocks will be merged', function()
  1421. write_file('Xdifile1', '')
  1422. write_file('Xdifile2', '')
  1423. write_file('Xdifile3', '')
  1424. finally(function()
  1425. os.remove('Xdifile1')
  1426. os.remove('Xdifile2')
  1427. os.remove('Xdifile3')
  1428. os.remove('Xdiin1')
  1429. os.remove('Xdinew1')
  1430. os.remove('Xdiout1')
  1431. os.remove('Xdiin2')
  1432. os.remove('Xdinew2')
  1433. os.remove('Xdiout2')
  1434. end)
  1435. exec([[
  1436. func DiffExprStub()
  1437. let txt_in = readfile(v:fname_in)
  1438. let txt_new = readfile(v:fname_new)
  1439. if txt_in == ["line1"] && txt_new == ["line2"]
  1440. call writefile(["1c1"], v:fname_out)
  1441. elseif txt_in == readfile("Xdiin1") && txt_new == readfile("Xdinew1")
  1442. call writefile(readfile("Xdiout1"), v:fname_out)
  1443. elseif txt_in == readfile("Xdiin2") && txt_new == readfile("Xdinew2")
  1444. call writefile(readfile("Xdiout2"), v:fname_out)
  1445. endif
  1446. endfunc
  1447. ]])
  1448. local screen = Screen.new(35, 20)
  1449. command('set winwidth=10 diffopt=filler,internal')
  1450. command('args Xdifile1 Xdifile2 | vert all | windo diffthis')
  1451. WriteDiffFiles('a\nb', 'x\nx')
  1452. write_file('Xdiin1', 'a\nb')
  1453. write_file('Xdinew1', 'x\nx')
  1454. write_file('Xdiout1', '1c1\n2c2')
  1455. command('set diffexpr=DiffExprStub()')
  1456. screen:expect([[
  1457. {7: }{27:a}{4: }│{7: }{27:^x}{4: }|
  1458. {7: }{27:b}{4: }│{7: }{27:x}{4: }|
  1459. {1:~ }│{1:~ }|*16
  1460. {2:Xdifile1 }{3:Xdifile2 }|
  1461. |
  1462. ]])
  1463. command('set diffexpr&')
  1464. WriteDiffFiles('a\nb\nc', 'x\nc')
  1465. write_file('Xdiin1', 'a\nb\nc')
  1466. write_file('Xdinew1', 'x\nc')
  1467. write_file('Xdiout1', '1c1\n2c1')
  1468. command('set diffexpr=DiffExprStub()')
  1469. screen:expect([[
  1470. {7: }{27:a}{4: }│{7: }{27:^x}{4: }|
  1471. {7: }{22:b }│{7: }{23:---------------}|
  1472. {7: }c │{7: }c |
  1473. {1:~ }│{1:~ }|*15
  1474. {2:Xdifile1 }{3:Xdifile2 }|
  1475. |
  1476. ]])
  1477. command('set diffexpr&')
  1478. WriteDiffFiles('a\nc', 'x\nx\nc')
  1479. write_file('Xdiin1', 'a\nc')
  1480. write_file('Xdinew1', 'x\nx\nc')
  1481. write_file('Xdiout1', '1c1\n1a2')
  1482. command('set diffexpr=DiffExprStub()')
  1483. screen:expect([[
  1484. {7: }{27:a}{4: }│{7: }{27:^x}{4: }|
  1485. {7: }{23:---------------}│{7: }{22:x }|
  1486. {7: }c │{7: }c |
  1487. {1:~ }│{1:~ }|*15
  1488. {2:Xdifile1 }{3:Xdifile2 }|
  1489. |
  1490. ]])
  1491. command('set diffexpr&')
  1492. command('args Xdifile1 Xdifile2 Xdifile3 | vert all | windo diffthis')
  1493. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'y\nb\nc')
  1494. screen:expect([[
  1495. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }|
  1496. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1497. {7: }c │{7: }c │{7: }c |
  1498. {1:~ }│{1:~ }│{1:~ }|*15
  1499. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1500. |
  1501. ]])
  1502. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'a\ny\nc')
  1503. screen:expect([[
  1504. {7: }a │{7: }a │{7: }^a |
  1505. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1506. {7: }c │{7: }c │{7: }c |
  1507. {1:~ }│{1:~ }│{1:~ }|*15
  1508. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1509. |
  1510. ]])
  1511. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'a\nb\ny')
  1512. screen:expect([[
  1513. {7: }a │{7: }a │{7: }^a |
  1514. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1515. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1516. {1:~ }│{1:~ }│{1:~ }|*15
  1517. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1518. |
  1519. ]])
  1520. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'y\ny\nc')
  1521. screen:expect([[
  1522. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }|
  1523. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1524. {7: }c │{7: }c │{7: }c |
  1525. {1:~ }│{1:~ }│{1:~ }|*15
  1526. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1527. |
  1528. ]])
  1529. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'a\ny\ny')
  1530. screen:expect([[
  1531. {7: }a │{7: }a │{7: }^a |
  1532. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1533. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1534. {1:~ }│{1:~ }│{1:~ }|*15
  1535. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1536. |
  1537. ]])
  1538. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'y\ny\ny')
  1539. screen:expect([[
  1540. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }|
  1541. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1542. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1543. {1:~ }│{1:~ }│{1:~ }|*15
  1544. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1545. |
  1546. ]])
  1547. WriteDiffFiles3('a\nb\nc', 'a\nx\nx', 'y\ny\nc')
  1548. screen:expect([[
  1549. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }|
  1550. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1551. {7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:c}{4: }|
  1552. {1:~ }│{1:~ }│{1:~ }|*15
  1553. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1554. |
  1555. ]])
  1556. WriteDiffFiles3('a\nb\nc', 'x\nx\nc', 'a\ny\ny')
  1557. screen:expect([[
  1558. {7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^a}{4: }|
  1559. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1560. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1561. {1:~ }│{1:~ }│{1:~ }|*15
  1562. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1563. |
  1564. ]])
  1565. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'y\ny\ny\nd\ne')
  1566. screen:expect([[
  1567. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }|
  1568. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1569. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1570. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }|
  1571. {7: }e │{7: }e │{7: }e |
  1572. {1:~ }│{1:~ }│{1:~ }|*13
  1573. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1574. |
  1575. ]])
  1576. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'y\ny\ny\ny\ne')
  1577. screen:expect([[
  1578. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }|
  1579. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1580. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1581. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1582. {7: }e │{7: }e │{7: }e |
  1583. {1:~ }│{1:~ }│{1:~ }|*13
  1584. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1585. |
  1586. ]])
  1587. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'y\ny\ny\ny\ny')
  1588. screen:expect([[
  1589. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^y}{4: }|
  1590. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1591. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1592. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1593. {7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:y}{4: }|
  1594. {1:~ }│{1:~ }│{1:~ }|*13
  1595. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1596. |
  1597. ]])
  1598. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\ny\ny\nd\ne')
  1599. screen:expect([[
  1600. {7: }a │{7: }a │{7: }^a |
  1601. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1602. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1603. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }|
  1604. {7: }e │{7: }e │{7: }e |
  1605. {1:~ }│{1:~ }│{1:~ }|*13
  1606. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1607. |
  1608. ]])
  1609. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\ny\ny\ny\ne')
  1610. screen:expect([[
  1611. {7: }a │{7: }a │{7: }^a |
  1612. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1613. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1614. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1615. {7: }e │{7: }e │{7: }e |
  1616. {1:~ }│{1:~ }│{1:~ }|*13
  1617. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1618. |
  1619. ]])
  1620. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\ny\ny\ny\ny')
  1621. screen:expect([[
  1622. {7: }a │{7: }a │{7: }^a |
  1623. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1624. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1625. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1626. {7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:y}{4: }|
  1627. {1:~ }│{1:~ }│{1:~ }|*13
  1628. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1629. |
  1630. ]])
  1631. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\nb\ny\nd\ne')
  1632. screen:expect([[
  1633. {7: }a │{7: }a │{7: }^a |
  1634. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1635. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1636. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }|
  1637. {7: }e │{7: }e │{7: }e |
  1638. {1:~ }│{1:~ }│{1:~ }|*13
  1639. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1640. |
  1641. ]])
  1642. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\nb\ny\ny\ne')
  1643. screen:expect([[
  1644. {7: }a │{7: }a │{7: }^a |
  1645. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1646. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1647. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1648. {7: }e │{7: }e │{7: }e |
  1649. {1:~ }│{1:~ }│{1:~ }|*13
  1650. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1651. |
  1652. ]])
  1653. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\nb\ny\ny\ny')
  1654. screen:expect([[
  1655. {7: }a │{7: }a │{7: }^a |
  1656. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1657. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:y}{4: }|
  1658. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1659. {7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:y}{4: }|
  1660. {1:~ }│{1:~ }│{1:~ }|*13
  1661. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1662. |
  1663. ]])
  1664. WriteDiffFiles3('a\nb', 'x\nb', 'y\ny')
  1665. write_file('Xdiin1', 'a\nb')
  1666. write_file('Xdinew1', 'x\nb')
  1667. write_file('Xdiout1', '1c1')
  1668. write_file('Xdiin2', 'a\nb')
  1669. write_file('Xdinew2', 'y\ny')
  1670. write_file('Xdiout2', '1c1\n2c2')
  1671. command('set diffexpr=DiffExprStub()')
  1672. screen:expect([[
  1673. {7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }|
  1674. {7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }|
  1675. {1:~ }│{1:~ }│{1:~ }|*16
  1676. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1677. |
  1678. ]])
  1679. command('set diffexpr&')
  1680. WriteDiffFiles3('a\nb\nc\nd', 'x\nb\nx\nd', 'y\ny\nc\nd')
  1681. write_file('Xdiin1', 'a\nb\nc\nd')
  1682. write_file('Xdinew1', 'x\nb\nx\nd')
  1683. write_file('Xdiout1', '1c1\n3c3')
  1684. write_file('Xdiin2', 'a\nb\nc\nd')
  1685. write_file('Xdinew2', 'y\ny\nc\nd')
  1686. write_file('Xdiout2', '1c1\n2c2')
  1687. command('set diffexpr=DiffExprStub()')
  1688. screen:expect([[
  1689. {7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }|
  1690. {7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }|
  1691. {7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:c}{4: }|
  1692. {7: }d │{7: }d │{7: }d |
  1693. {1:~ }│{1:~ }│{1:~ }|*14
  1694. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1695. |
  1696. ]])
  1697. command('set diffexpr&')
  1698. WriteDiffFiles3('a\nb\nc\nd', 'x\nb\nx\nd', 'y\ny\ny\nd')
  1699. write_file('Xdiin1', 'a\nb\nc\nd')
  1700. write_file('Xdinew1', 'x\nb\nx\nd')
  1701. write_file('Xdiout1', '1c1\n3c3')
  1702. write_file('Xdiin2', 'a\nb\nc\nd')
  1703. write_file('Xdinew2', 'y\ny\ny\nd')
  1704. write_file('Xdiout2', '1c1\n2,3c2,3')
  1705. command('set diffexpr=DiffExprStub()')
  1706. screen:expect([[
  1707. {7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }|
  1708. {7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }|
  1709. {7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1710. {7: }d │{7: }d │{7: }d |
  1711. {1:~ }│{1:~ }│{1:~ }|*14
  1712. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1713. |
  1714. ]])
  1715. command('set diffexpr&')
  1716. WriteDiffFiles3('a\nb\nc\nd', 'x\nb\nx\nd', 'y\ny\ny\ny')
  1717. write_file('Xdiin1', 'a\nb\nc\nd')
  1718. write_file('Xdinew1', 'x\nb\nx\nd')
  1719. write_file('Xdiout1', '1c1\n3c3')
  1720. write_file('Xdiin2', 'a\nb\nc\nd')
  1721. write_file('Xdinew2', 'y\ny\ny\ny')
  1722. write_file('Xdiout2', '1c1\n2,4c2,4')
  1723. command('set diffexpr=DiffExprStub()')
  1724. screen:expect([[
  1725. {7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:^y}{4: }|
  1726. {7: }{27:b}{4: }│{7: }{27:b}{4: }│{7: }{27:y}{4: }|
  1727. {7: }{27:c}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1728. {7: }{27:d}{4: }│{7: }{27:d}{4: }│{7: }{27:y}{4: }|
  1729. {1:~ }│{1:~ }│{1:~ }|*14
  1730. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1731. |
  1732. ]])
  1733. command('set diffexpr&')
  1734. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'b\nc')
  1735. screen:expect([[
  1736. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^b}{4: }|
  1737. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1738. {7: }c │{7: }c │{7: }c |
  1739. {1:~ }│{1:~ }│{1:~ }|*15
  1740. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1741. |
  1742. ]])
  1743. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'c')
  1744. screen:expect([[
  1745. {7: }{4:a }│{7: }{4:a }│{7: }{23:---------}|
  1746. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1747. {7: }c │{7: }c │{7: }^c |
  1748. {1:~ }│{1:~ }│{1:~ }|*15
  1749. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1750. |
  1751. ]])
  1752. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', '')
  1753. screen:expect([[
  1754. {7: }{4:a }│{7: }{4:a }│{7: }{23:---------}|
  1755. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1756. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1757. {1:~ }│{1:~ }│{7: }^ |
  1758. {1:~ }│{1:~ }│{1:~ }|*14
  1759. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1760. |
  1761. ]])
  1762. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'a\nc')
  1763. screen:expect([[
  1764. {7: }a │{7: }a │{7: }^a |
  1765. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1766. {7: }c │{7: }c │{7: }c |
  1767. {1:~ }│{1:~ }│{1:~ }|*15
  1768. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1769. |
  1770. ]])
  1771. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'a')
  1772. screen:expect([[
  1773. {7: }a │{7: }a │{7: }^a |
  1774. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1775. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1776. {1:~ }│{1:~ }│{1:~ }|*15
  1777. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1778. |
  1779. ]])
  1780. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'b')
  1781. screen:expect([[
  1782. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^b}{4: }|
  1783. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1784. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1785. {1:~ }│{1:~ }│{1:~ }|*15
  1786. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1787. |
  1788. ]])
  1789. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'd\ne')
  1790. screen:expect([[
  1791. {7: }{27:a}{4: }│{7: }{27:a}{4: }│{7: }{27:^d}{4: }|
  1792. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1793. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1794. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1795. {7: }e │{7: }e │{7: }e |
  1796. {1:~ }│{1:~ }│{1:~ }|*13
  1797. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1798. |
  1799. ]])
  1800. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'e')
  1801. screen:expect([[
  1802. {7: }{4:a }│{7: }{4:a }│{7: }{23:---------}|
  1803. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1804. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1805. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1806. {7: }e │{7: }e │{7: }^e |
  1807. {1:~ }│{1:~ }│{1:~ }|*13
  1808. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1809. |
  1810. ]])
  1811. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\nd\ne')
  1812. screen:expect([[
  1813. {7: }a │{7: }a │{7: }^a |
  1814. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:d}{4: }|
  1815. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1816. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1817. {7: }e │{7: }e │{7: }e |
  1818. {1:~ }│{1:~ }│{1:~ }|*13
  1819. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1820. |
  1821. ]])
  1822. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\ne')
  1823. screen:expect([[
  1824. {7: }a │{7: }a │{7: }^a |
  1825. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1826. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1827. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1828. {7: }e │{7: }e │{7: }e |
  1829. {1:~ }│{1:~ }│{1:~ }|*13
  1830. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1831. |
  1832. ]])
  1833. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a')
  1834. screen:expect([[
  1835. {7: }a │{7: }a │{7: }^a |
  1836. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1837. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1838. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1839. {7: }{4:e }│{7: }{4:e }│{7: }{23:---------}|
  1840. {1:~ }│{1:~ }│{1:~ }|*13
  1841. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1842. |
  1843. ]])
  1844. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\nb\nd\ne')
  1845. screen:expect([[
  1846. {7: }a │{7: }a │{7: }^a |
  1847. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1848. {7: }{27:c}{4: }│{7: }{27:c}{4: }│{7: }{27:d}{4: }|
  1849. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1850. {7: }e │{7: }e │{7: }e |
  1851. {1:~ }│{1:~ }│{1:~ }|*13
  1852. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1853. |
  1854. ]])
  1855. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\nb\ne')
  1856. screen:expect([[
  1857. {7: }a │{7: }a │{7: }^a |
  1858. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1859. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1860. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1861. {7: }e │{7: }e │{7: }e |
  1862. {1:~ }│{1:~ }│{1:~ }|*13
  1863. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1864. |
  1865. ]])
  1866. WriteDiffFiles3('a\nb\nc\nd\ne', 'a\nx\nc\nx\ne', 'a\nb')
  1867. screen:expect([[
  1868. {7: }a │{7: }a │{7: }^a |
  1869. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1870. {7: }{4:c }│{7: }{4:c }│{7: }{23:---------}|
  1871. {7: }{27:d}{4: }│{7: }{27:x}{4: }│{7: }{23:---------}|
  1872. {7: }{4:e }│{7: }{4:e }│{7: }{23:---------}|
  1873. {1:~ }│{1:~ }│{1:~ }|*13
  1874. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1875. |
  1876. ]])
  1877. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'a\ny\nb\nc')
  1878. screen:expect([[
  1879. {7: }a │{7: }a │{7: }^a |
  1880. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:y}{4: }|
  1881. {7: }{23:---------}│{7: }{23:---------}│{7: }{22:b }|
  1882. {7: }c │{7: }c │{7: }c |
  1883. {1:~ }│{1:~ }│{1:~ }|*14
  1884. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1885. |
  1886. ]])
  1887. WriteDiffFiles3('a\nb\nc', 'a\nx\nc', 'a\nb\ny\nc')
  1888. screen:expect([[
  1889. {7: }a │{7: }a │{7: }^a |
  1890. {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
  1891. {7: }{23:---------}│{7: }{23:---------}│{7: }{22:y }|
  1892. {7: }c │{7: }c │{7: }c |
  1893. {1:~ }│{1:~ }│{1:~ }|*14
  1894. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1895. |
  1896. ]])
  1897. WriteDiffFiles3('a\nb\nc', 'd\ne', 'b\nf')
  1898. screen:expect([[
  1899. {7: }{27:a}{4: }│{7: }{27:d}{4: }│{7: }{27:^b}{4: }|
  1900. {7: }{27:b}{4: }│{7: }{27:e}{4: }│{7: }{27:f}{4: }|
  1901. {7: }{22:c }│{7: }{23:---------}│{7: }{23:---------}|
  1902. {1:~ }│{1:~ }│{1:~ }|*15
  1903. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1904. |
  1905. ]])
  1906. WriteDiffFiles3('a\nb\nc', 'd\ne', 'b')
  1907. screen:expect([[
  1908. {7: }{27:a}{4: }│{7: }{27:d}{4: }│{7: }{27:^b}{4: }|
  1909. {7: }{27:b}{4: }│{7: }{27:e}{4: }│{7: }{23:---------}|
  1910. {7: }{22:c }│{7: }{23:---------}│{7: }{23:---------}|
  1911. {1:~ }│{1:~ }│{1:~ }|*15
  1912. {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
  1913. |
  1914. ]])
  1915. end)
  1916. -- oldtest: Test_diff_topline_noscroll()
  1917. it('diff mode does not scroll with line("w0")', function()
  1918. local screen = Screen.new(45, 20)
  1919. exec([[
  1920. set scrolloff=5
  1921. call setline(1, range(1,60))
  1922. vnew
  1923. call setline(1, range(1,10) + range(50,60))
  1924. windo diffthis
  1925. norm! G
  1926. exe "norm! 30\<C-y>"
  1927. ]])
  1928. screen:expect([[
  1929. {7: }9 │{7: }9 |
  1930. {7: }10 │{7: }10 |
  1931. {7: }{23:--------------------}│{7: }{22:11 }|
  1932. {7: }{23:--------------------}│{7: }{22:12 }|
  1933. {7: }{23:--------------------}│{7: }{22:13 }|
  1934. {7: }{23:--------------------}│{7: }{22:14 }|
  1935. {7: }{23:--------------------}│{7: }{22:15 }|
  1936. {7: }{23:--------------------}│{7: }{22:16 }|
  1937. {7: }{23:--------------------}│{7: }{22:17 }|
  1938. {7: }{23:--------------------}│{7: }{22:18 }|
  1939. {7: }{23:--------------------}│{7: }{22:19 }|
  1940. {7: }{23:--------------------}│{7: }{22:20 }|
  1941. {7: }{23:--------------------}│{7: }{22:^21 }|
  1942. {7: }{23:--------------------}│{7: }{22:22 }|
  1943. {7: }{23:--------------------}│{7: }{22:23 }|
  1944. {7: }{23:--------------------}│{7: }{22:24 }|
  1945. {7: }{23:--------------------}│{7: }{22:25 }|
  1946. {7: }{23:--------------------}│{7: }{22:26 }|
  1947. {2:[No Name] [+] }{3:[No Name] [+] }|
  1948. |
  1949. ]])
  1950. command([[echo line('w0', 1001)]])
  1951. screen:expect([[
  1952. {7: }9 │{7: }9 |
  1953. {7: }10 │{7: }10 |
  1954. {7: }{23:--------------------}│{7: }{22:11 }|
  1955. {7: }{23:--------------------}│{7: }{22:12 }|
  1956. {7: }{23:--------------------}│{7: }{22:13 }|
  1957. {7: }{23:--------------------}│{7: }{22:14 }|
  1958. {7: }{23:--------------------}│{7: }{22:15 }|
  1959. {7: }{23:--------------------}│{7: }{22:16 }|
  1960. {7: }{23:--------------------}│{7: }{22:17 }|
  1961. {7: }{23:--------------------}│{7: }{22:18 }|
  1962. {7: }{23:--------------------}│{7: }{22:19 }|
  1963. {7: }{23:--------------------}│{7: }{22:20 }|
  1964. {7: }{23:--------------------}│{7: }{22:^21 }|
  1965. {7: }{23:--------------------}│{7: }{22:22 }|
  1966. {7: }{23:--------------------}│{7: }{22:23 }|
  1967. {7: }{23:--------------------}│{7: }{22:24 }|
  1968. {7: }{23:--------------------}│{7: }{22:25 }|
  1969. {7: }{23:--------------------}│{7: }{22:26 }|
  1970. {2:[No Name] [+] }{3:[No Name] [+] }|
  1971. 9 |
  1972. ]])
  1973. feed('<C-W>p')
  1974. screen:expect([[
  1975. {7: }{23:--------------------}│{7: }{22:39 }|
  1976. {7: }{23:--------------------}│{7: }{22:40 }|
  1977. {7: }{23:--------------------}│{7: }{22:41 }|
  1978. {7: }{23:--------------------}│{7: }{22:42 }|
  1979. {7: }{23:--------------------}│{7: }{22:43 }|
  1980. {7: }{23:--------------------}│{7: }{22:44 }|
  1981. {7: }{23:--------------------}│{7: }{22:45 }|
  1982. {7: }{23:--------------------}│{7: }{22:46 }|
  1983. {7: }{23:--------------------}│{7: }{22:47 }|
  1984. {7: }{23:--------------------}│{7: }{22:48 }|
  1985. {7: }{23:--------------------}│{7: }{22:49 }|
  1986. {7: }^50 │{7: }50 |
  1987. {7: }51 │{7: }51 |
  1988. {7: }52 │{7: }52 |
  1989. {7: }53 │{7: }53 |
  1990. {7: }54 │{7: }54 |
  1991. {7: }55 │{7: }55 |
  1992. {7:+ }{13:+-- 5 lines: 56····}│{7:+ }{13:+-- 5 lines: 56····}|
  1993. {3:[No Name] [+] }{2:[No Name] [+] }|
  1994. 9 |
  1995. ]])
  1996. feed('<C-W>p')
  1997. screen:expect([[
  1998. {7: }{23:--------------------}│{7: }{22:39 }|
  1999. {7: }{23:--------------------}│{7: }{22:40 }|
  2000. {7: }{23:--------------------}│{7: }{22:41 }|
  2001. {7: }{23:--------------------}│{7: }{22:42 }|
  2002. {7: }{23:--------------------}│{7: }{22:43 }|
  2003. {7: }{23:--------------------}│{7: }{22:^44 }|
  2004. {7: }{23:--------------------}│{7: }{22:45 }|
  2005. {7: }{23:--------------------}│{7: }{22:46 }|
  2006. {7: }{23:--------------------}│{7: }{22:47 }|
  2007. {7: }{23:--------------------}│{7: }{22:48 }|
  2008. {7: }{23:--------------------}│{7: }{22:49 }|
  2009. {7: }50 │{7: }50 |
  2010. {7: }51 │{7: }51 |
  2011. {7: }52 │{7: }52 |
  2012. {7: }53 │{7: }53 |
  2013. {7: }54 │{7: }54 |
  2014. {7: }55 │{7: }55 |
  2015. {7:+ }{13:+-- 5 lines: 56····}│{7:+ }{13:+-- 5 lines: 56····}|
  2016. {2:[No Name] [+] }{3:[No Name] [+] }|
  2017. 9 |
  2018. ]])
  2019. end)