diff_spec.lua 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local feed = helpers.feed
  4. local clear = helpers.clear
  5. local command = helpers.command
  6. local insert = helpers.insert
  7. local write_file = helpers.write_file
  8. local dedent = helpers.dedent
  9. local exec = helpers.exec
  10. local eq = helpers.eq
  11. local meths = helpers.meths
  12. before_each(clear)
  13. describe('Diff mode screen', function()
  14. local fname = 'Xtest-functional-diff-screen-1'
  15. local fname_2 = fname .. '.2'
  16. local screen
  17. local reread = function()
  18. feed(':e<cr><c-w>w:e<cr><c-w>w')
  19. end
  20. setup(function()
  21. os.remove(fname)
  22. os.remove(fname_2)
  23. end)
  24. teardown(function()
  25. os.remove(fname)
  26. os.remove(fname_2)
  27. end)
  28. before_each(function()
  29. feed(':e ' .. fname_2 .. '<cr>')
  30. feed(':vnew ' .. fname .. '<cr>')
  31. feed(':diffthis<cr>')
  32. feed('<c-w>w:diffthis<cr><c-w>w')
  33. screen = Screen.new(40, 16)
  34. screen:attach()
  35. screen:set_default_attr_ids({
  36. [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  37. [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
  38. [3] = {reverse = true},
  39. [4] = {background = Screen.colors.LightBlue},
  40. [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
  41. [6] = {bold = true, foreground = Screen.colors.Blue1},
  42. [7] = {bold = true, reverse = true},
  43. [8] = {bold = true, background = Screen.colors.Red},
  44. [9] = {background = Screen.colors.LightMagenta},
  45. })
  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. {1: }{2:------------------}│{1: }{4:0 }|
  54. {1: }^1 │{1: }1 |
  55. {1: }2 │{1: }2 |
  56. {1: }3 │{1: }3 |
  57. {1: }4 │{1: }4 |
  58. {1: }5 │{1: }5 |
  59. {1: }6 │{1: }6 |
  60. {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
  61. {6:~ }│{6:~ }|
  62. {6:~ }│{6:~ }|
  63. {6:~ }│{6:~ }|
  64. {6:~ }│{6:~ }|
  65. {6:~ }│{6:~ }|
  66. {6:~ }│{6:~ }|
  67. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  68. :set diffopt=filler |
  69. ]])
  70. feed(':set diffopt+=internal<cr>')
  71. screen:expect([[
  72. {1: }{2:------------------}│{1: }{4:0 }|
  73. {1: }^1 │{1: }1 |
  74. {1: }2 │{1: }2 |
  75. {1: }3 │{1: }3 |
  76. {1: }4 │{1: }4 |
  77. {1: }5 │{1: }5 |
  78. {1: }6 │{1: }6 |
  79. {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
  80. {6:~ }│{6:~ }|
  81. {6:~ }│{6:~ }|
  82. {6:~ }│{6:~ }|
  83. {6:~ }│{6:~ }|
  84. {6:~ }│{6:~ }|
  85. {6:~ }│{6:~ }|
  86. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  87. :set diffopt+=internal |
  88. ]])
  89. end)
  90. it('Add a line in beginning of file 1', function()
  91. write_file(fname, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  92. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  93. reread()
  94. feed(":set diffopt=filler<cr>")
  95. screen:expect([[
  96. {1: }{4:^0 }│{1: }{2:-----------------}|
  97. {1: }1 │{1: }1 |
  98. {1: }2 │{1: }2 |
  99. {1: }3 │{1: }3 |
  100. {1: }4 │{1: }4 |
  101. {1: }5 │{1: }5 |
  102. {1: }6 │{1: }6 |
  103. {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
  104. {6:~ }│{6:~ }|
  105. {6:~ }│{6:~ }|
  106. {6:~ }│{6:~ }|
  107. {6:~ }│{6:~ }|
  108. {6:~ }│{6:~ }|
  109. {6:~ }│{6:~ }|
  110. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  111. :set diffopt=filler |
  112. ]])
  113. feed(":set diffopt+=internal<cr>")
  114. screen:expect([[
  115. {1: }{4:^0 }│{1: }{2:-----------------}|
  116. {1: }1 │{1: }1 |
  117. {1: }2 │{1: }2 |
  118. {1: }3 │{1: }3 |
  119. {1: }4 │{1: }4 |
  120. {1: }5 │{1: }5 |
  121. {1: }6 │{1: }6 |
  122. {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}|
  123. {6:~ }│{6:~ }|
  124. {6:~ }│{6:~ }|
  125. {6:~ }│{6:~ }|
  126. {6:~ }│{6:~ }|
  127. {6:~ }│{6:~ }|
  128. {6:~ }│{6:~ }|
  129. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  130. :set diffopt+=internal |
  131. ]])
  132. end)
  133. it('Add a line at the end of file 2', function()
  134. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  135. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  136. reread()
  137. feed(":set diffopt=filler<cr>")
  138. screen:expect([[
  139. {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
  140. {1: }5 │{1: }5 |
  141. {1: }6 │{1: }6 |
  142. {1: }7 │{1: }7 |
  143. {1: }8 │{1: }8 |
  144. {1: }9 │{1: }9 |
  145. {1: }10 │{1: }10 |
  146. {1: }{2:------------------}│{1: }{4:11 }|
  147. {6:~ }│{6:~ }|
  148. {6:~ }│{6:~ }|
  149. {6:~ }│{6:~ }|
  150. {6:~ }│{6:~ }|
  151. {6:~ }│{6:~ }|
  152. {6:~ }│{6:~ }|
  153. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  154. :set diffopt=filler |
  155. ]])
  156. feed(":set diffopt+=internal<cr>")
  157. screen:expect([[
  158. {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
  159. {1: }5 │{1: }5 |
  160. {1: }6 │{1: }6 |
  161. {1: }7 │{1: }7 |
  162. {1: }8 │{1: }8 |
  163. {1: }9 │{1: }9 |
  164. {1: }10 │{1: }10 |
  165. {1: }{2:------------------}│{1: }{4:11 }|
  166. {6:~ }│{6:~ }|
  167. {6:~ }│{6:~ }|
  168. {6:~ }│{6:~ }|
  169. {6:~ }│{6:~ }|
  170. {6:~ }│{6:~ }|
  171. {6:~ }│{6:~ }|
  172. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  173. :set diffopt+=internal |
  174. ]])
  175. screen:try_resize(40, 9)
  176. screen:expect([[
  177. {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
  178. {1: }5 │{1: }5 |
  179. {1: }6 │{1: }6 |
  180. {1: }7 │{1: }7 |
  181. {1: }8 │{1: }8 |
  182. {1: }9 │{1: }9 |
  183. {1: }10 │{1: }10 |
  184. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  185. |
  186. ]])
  187. end)
  188. it('Add a line at the end of file 1', function()
  189. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  190. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  191. reread()
  192. feed(":set diffopt=filler<cr>")
  193. screen:expect([[
  194. {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
  195. {1: }5 │{1: }5 |
  196. {1: }6 │{1: }6 |
  197. {1: }7 │{1: }7 |
  198. {1: }8 │{1: }8 |
  199. {1: }9 │{1: }9 |
  200. {1: }10 │{1: }10 |
  201. {1: }{4:11 }│{1: }{2:-----------------}|
  202. {6:~ }│{6:~ }|
  203. {6:~ }│{6:~ }|
  204. {6:~ }│{6:~ }|
  205. {6:~ }│{6:~ }|
  206. {6:~ }│{6:~ }|
  207. {6:~ }│{6:~ }|
  208. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  209. :set diffopt=filler |
  210. ]])
  211. feed(":set diffopt+=internal<cr>")
  212. screen:expect([[
  213. {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
  214. {1: }5 │{1: }5 |
  215. {1: }6 │{1: }6 |
  216. {1: }7 │{1: }7 |
  217. {1: }8 │{1: }8 |
  218. {1: }9 │{1: }9 |
  219. {1: }10 │{1: }10 |
  220. {1: }{4:11 }│{1: }{2:-----------------}|
  221. {6:~ }│{6:~ }|
  222. {6:~ }│{6:~ }|
  223. {6:~ }│{6:~ }|
  224. {6:~ }│{6:~ }|
  225. {6:~ }│{6:~ }|
  226. {6:~ }│{6:~ }|
  227. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  228. :set diffopt+=internal |
  229. ]])
  230. screen:try_resize(40, 9)
  231. screen:expect([[
  232. {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}|
  233. {1: }5 │{1: }5 |
  234. {1: }6 │{1: }6 |
  235. {1: }7 │{1: }7 |
  236. {1: }8 │{1: }8 |
  237. {1: }9 │{1: }9 |
  238. {1: }10 │{1: }10 |
  239. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  240. |
  241. ]])
  242. end)
  243. it('Add a line in the middle of file 2, remove on at the end of file 1', function()
  244. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  245. write_file(fname_2, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
  246. reread()
  247. feed(':set diffopt=filler<cr>')
  248. screen:expect([[
  249. {1: }^1 │{1: }1 |
  250. {1: }2 │{1: }2 |
  251. {1: }3 │{1: }3 |
  252. {1: }4 │{1: }4 |
  253. {1: }{2:------------------}│{1: }{4:4 }|
  254. {1: }5 │{1: }5 |
  255. {1: }6 │{1: }6 |
  256. {1: }7 │{1: }7 |
  257. {1: }8 │{1: }8 |
  258. {1: }9 │{1: }9 |
  259. {1: }10 │{1: }10 |
  260. {1: }{4:11 }│{1: }{2:-----------------}|
  261. {6:~ }│{6:~ }|
  262. {6:~ }│{6:~ }|
  263. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  264. :set diffopt=filler |
  265. ]])
  266. feed(':set diffopt+=internal<cr>')
  267. screen:expect([[
  268. {1: }^1 │{1: }1 |
  269. {1: }2 │{1: }2 |
  270. {1: }3 │{1: }3 |
  271. {1: }4 │{1: }4 |
  272. {1: }{2:------------------}│{1: }{4:4 }|
  273. {1: }5 │{1: }5 |
  274. {1: }6 │{1: }6 |
  275. {1: }7 │{1: }7 |
  276. {1: }8 │{1: }8 |
  277. {1: }9 │{1: }9 |
  278. {1: }10 │{1: }10 |
  279. {1: }{4:11 }│{1: }{2:-----------------}|
  280. {6:~ }│{6:~ }|
  281. {6:~ }│{6:~ }|
  282. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  283. :set diffopt+=internal |
  284. ]])
  285. end)
  286. it('Add a line in the middle of file 1, remove on at the end of file 2', function()
  287. write_file(fname, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
  288. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  289. reread()
  290. feed(':set diffopt=filler<cr>')
  291. screen:expect([[
  292. {1: }^1 │{1: }1 |
  293. {1: }2 │{1: }2 |
  294. {1: }3 │{1: }3 |
  295. {1: }4 │{1: }4 |
  296. {1: }{4:4 }│{1: }{2:-----------------}|
  297. {1: }5 │{1: }5 |
  298. {1: }6 │{1: }6 |
  299. {1: }7 │{1: }7 |
  300. {1: }8 │{1: }8 |
  301. {1: }9 │{1: }9 |
  302. {1: }10 │{1: }10 |
  303. {1: }{2:------------------}│{1: }{4:11 }|
  304. {6:~ }│{6:~ }|
  305. {6:~ }│{6:~ }|
  306. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  307. :set diffopt=filler |
  308. ]])
  309. feed(':set diffopt+=internal<cr>')
  310. screen:expect([[
  311. {1: }^1 │{1: }1 |
  312. {1: }2 │{1: }2 |
  313. {1: }3 │{1: }3 |
  314. {1: }4 │{1: }4 |
  315. {1: }{4:4 }│{1: }{2:-----------------}|
  316. {1: }5 │{1: }5 |
  317. {1: }6 │{1: }6 |
  318. {1: }7 │{1: }7 |
  319. {1: }8 │{1: }8 |
  320. {1: }9 │{1: }9 |
  321. {1: }10 │{1: }10 |
  322. {1: }{2:------------------}│{1: }{4:11 }|
  323. {6:~ }│{6:~ }|
  324. {6:~ }│{6:~ }|
  325. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  326. :set diffopt+=internal |
  327. ]])
  328. end)
  329. describe('normal/patience/histogram diff algorithm', function()
  330. setup(function()
  331. local f1 = [[#include <stdio.h>
  332. // Frobs foo heartily
  333. int frobnitz(int foo)
  334. {
  335. int i;
  336. for(i = 0; i < 10; i++)
  337. {
  338. printf("Your answer is: ");
  339. printf("%d\n", foo);
  340. }
  341. }
  342. int fact(int n)
  343. {
  344. if(n > 1)
  345. {
  346. return fact(n-1) * n;
  347. }
  348. return 1;
  349. }
  350. int main(int argc, char **argv)
  351. {
  352. frobnitz(fact(10));
  353. }]]
  354. write_file(fname, f1, false)
  355. local f2 = [[#include <stdio.h>
  356. int fib(int n)
  357. {
  358. if(n > 2)
  359. {
  360. return fib(n-1) + fib(n-2);
  361. }
  362. return 1;
  363. }
  364. // Frobs foo heartily
  365. int frobnitz(int foo)
  366. {
  367. int i;
  368. for(i = 0; i < 10; i++)
  369. {
  370. printf("%d\n", foo);
  371. }
  372. }
  373. int main(int argc, char **argv)
  374. {
  375. frobnitz(fib(10));
  376. }]]
  377. write_file(fname_2, f2, false)
  378. end)
  379. it('diffopt=+algorithm:myers', function()
  380. reread()
  381. feed(':set diffopt=internal,filler<cr>')
  382. screen:expect([[
  383. {1: }^#include <stdio.h>│{1: }#include <stdio.h|
  384. {1: } │{1: } |
  385. {1: }{8:// Frobs foo heart}│{1: }{8:int fib(int n)}{9: }|
  386. {1: }{4:int frobnitz(int f}│{1: }{2:-----------------}|
  387. {1: }{ │{1: }{ |
  388. {1: }{9: i}{8:nt i;}{9: }│{1: }{9: i}{8:f(n > 2)}{9: }|
  389. {1: }{4: for(i = 0; i <}│{1: }{2:-----------------}|
  390. {1: } { │{1: } { |
  391. {1: }{9: }{8:printf("Yo}│{1: }{9: }{8:return fi}|
  392. {1: }{4: printf("%d}│{1: }{2:-----------------}|
  393. {1: } } │{1: } } |
  394. {1: }{2:------------------}│{1: }{4: return 1; }|
  395. {1: }} │{1: }} |
  396. {1: } │{1: } |
  397. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  398. :set diffopt=internal,filler |
  399. ]])
  400. feed('G')
  401. screen:expect([[
  402. {1: }{2:------------------}│{1: }{4:int frobnitz(int }|
  403. {1: }{ │{1: }{ |
  404. {1: }{9: i}{8:f(n > 1)}{9: }│{1: }{9: i}{8:nt i;}{9: }|
  405. {1: }{2:------------------}│{1: }{4: for(i = 0; i }|
  406. {1: } { │{1: } { |
  407. {1: }{9: }{8:return fac}│{1: }{9: }{8:printf("%}|
  408. {1: } } │{1: } } |
  409. {1: }{4: return 1; }│{1: }{2:-----------------}|
  410. {1: }} │{1: }} |
  411. {1: } │{1: } |
  412. {1: }int main(int argc,│{1: }int main(int argc|
  413. {1: }{ │{1: }{ |
  414. {1: }{9: frobnitz(f}{8:act}{9:(}│{1: }{9: frobnitz(f}{8:ib}{9:(}|
  415. {1: }^} │{1: }} |
  416. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  417. :set diffopt=internal,filler |
  418. ]])
  419. end)
  420. it('diffopt+=algorithm:patience', function()
  421. reread()
  422. feed(':set diffopt=internal,filler,algorithm:patience<cr>')
  423. screen:expect([[
  424. {1: }^#include <stdio.h>│{1: }#include <stdio.h|
  425. {1: } │{1: } |
  426. {1: }{2:------------------}│{1: }{4:int fib(int n) }|
  427. {1: }{2:------------------}│{1: }{4:{ }|
  428. {1: }{2:------------------}│{1: }{4: if(n > 2) }|
  429. {1: }{2:------------------}│{1: }{4: { }|
  430. {1: }{2:------------------}│{1: }{4: return fi}|
  431. {1: }{2:------------------}│{1: }{4: } }|
  432. {1: }{2:------------------}│{1: }{4: return 1; }|
  433. {1: }{2:------------------}│{1: }{4:} }|
  434. {1: }{2:------------------}│{1: }{4: }|
  435. {1: }// Frobs foo heart│{1: }// Frobs foo hear|
  436. {1: }int frobnitz(int f│{1: }int frobnitz(int |
  437. {1: }{ │{1: }{ |
  438. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  439. |
  440. ]])
  441. feed('G')
  442. screen:expect([[
  443. {1: } │{1: } |
  444. {1: }{4:int fact(int n) }│{1: }{2:-----------------}|
  445. {1: }{4:{ }│{1: }{2:-----------------}|
  446. {1: }{4: if(n > 1) }│{1: }{2:-----------------}|
  447. {1: }{4: { }│{1: }{2:-----------------}|
  448. {1: }{4: return fac}│{1: }{2:-----------------}|
  449. {1: }{4: } }│{1: }{2:-----------------}|
  450. {1: }{4: return 1; }│{1: }{2:-----------------}|
  451. {1: }{4:} }│{1: }{2:-----------------}|
  452. {1: }{4: }│{1: }{2:-----------------}|
  453. {1: }int main(int argc,│{1: }int main(int argc|
  454. {1: }{ │{1: }{ |
  455. {1: }{9: frobnitz(f}{8:act}{9:(}│{1: }{9: frobnitz(f}{8:ib}{9:(}|
  456. {1: }^} │{1: }} |
  457. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  458. |
  459. ]])
  460. end)
  461. it('diffopt+=algorithm:histogram', function()
  462. reread()
  463. feed(':set diffopt=internal,filler,algorithm:histogram<cr>')
  464. screen:expect([[
  465. {1: }^#include <stdio.h>│{1: }#include <stdio.h|
  466. {1: } │{1: } |
  467. {1: }{2:------------------}│{1: }{4:int fib(int n) }|
  468. {1: }{2:------------------}│{1: }{4:{ }|
  469. {1: }{2:------------------}│{1: }{4: if(n > 2) }|
  470. {1: }{2:------------------}│{1: }{4: { }|
  471. {1: }{2:------------------}│{1: }{4: return fi}|
  472. {1: }{2:------------------}│{1: }{4: } }|
  473. {1: }{2:------------------}│{1: }{4: return 1; }|
  474. {1: }{2:------------------}│{1: }{4:} }|
  475. {1: }{2:------------------}│{1: }{4: }|
  476. {1: }// Frobs foo heart│{1: }// Frobs foo hear|
  477. {1: }int frobnitz(int f│{1: }int frobnitz(int |
  478. {1: }{ │{1: }{ |
  479. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  480. |
  481. ]])
  482. feed('G')
  483. screen:expect([[
  484. {1: } │{1: } |
  485. {1: }{4:int fact(int n) }│{1: }{2:-----------------}|
  486. {1: }{4:{ }│{1: }{2:-----------------}|
  487. {1: }{4: if(n > 1) }│{1: }{2:-----------------}|
  488. {1: }{4: { }│{1: }{2:-----------------}|
  489. {1: }{4: return fac}│{1: }{2:-----------------}|
  490. {1: }{4: } }│{1: }{2:-----------------}|
  491. {1: }{4: return 1; }│{1: }{2:-----------------}|
  492. {1: }{4:} }│{1: }{2:-----------------}|
  493. {1: }{4: }│{1: }{2:-----------------}|
  494. {1: }int main(int argc,│{1: }int main(int argc|
  495. {1: }{ │{1: }{ |
  496. {1: }{9: frobnitz(f}{8:act}{9:(}│{1: }{9: frobnitz(f}{8:ib}{9:(}|
  497. {1: }^} │{1: }} |
  498. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  499. |
  500. ]])
  501. end)
  502. end)
  503. describe('diffopt+=indent-heuristic', function()
  504. setup(function()
  505. local f1 = [[
  506. def finalize(values)
  507. values.each do |v|
  508. v.finalize
  509. end]]
  510. write_file(fname, f1, false)
  511. local f2 = [[
  512. def finalize(values)
  513. values.each do |v|
  514. v.prepare
  515. end
  516. values.each do |v|
  517. v.finalize
  518. end]]
  519. write_file(fname_2, f2, false)
  520. feed(':diffupdate!<cr>')
  521. end)
  522. it('internal', function()
  523. reread()
  524. feed(":set diffopt=internal,filler<cr>")
  525. screen:expect([[
  526. {1: }^def finalize(value│{1: }def finalize(valu|
  527. {1: } │{1: } |
  528. {1: } values.each do |│{1: } values.each do |
  529. {1: }{2:------------------}│{1: }{4: v.prepare }|
  530. {1: }{2:------------------}│{1: }{4: end }|
  531. {1: }{2:------------------}│{1: }{4: }|
  532. {1: }{2:------------------}│{1: }{4: values.each do }|
  533. {1: } v.finalize │{1: } v.finalize |
  534. {1: } end │{1: } end |
  535. {6:~ }│{6:~ }|
  536. {6:~ }│{6:~ }|
  537. {6:~ }│{6:~ }|
  538. {6:~ }│{6:~ }|
  539. {6:~ }│{6:~ }|
  540. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  541. :set diffopt=internal,filler |
  542. ]])
  543. end)
  544. it('indent-heuristic', function()
  545. reread()
  546. feed(':set diffopt=internal,filler,indent-heuristic<cr>')
  547. screen:expect([[
  548. {1: }^def finalize(value│{1: }def finalize(valu|
  549. {1: } │{1: } |
  550. {1: }{2:------------------}│{1: }{4: values.each do }|
  551. {1: }{2:------------------}│{1: }{4: v.prepare }|
  552. {1: }{2:------------------}│{1: }{4: end }|
  553. {1: }{2:------------------}│{1: }{4: }|
  554. {1: } values.each do |│{1: } values.each do |
  555. {1: } v.finalize │{1: } v.finalize |
  556. {1: } end │{1: } end |
  557. {6:~ }│{6:~ }|
  558. {6:~ }│{6:~ }|
  559. {6:~ }│{6:~ }|
  560. {6:~ }│{6:~ }|
  561. {6:~ }│{6:~ }|
  562. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  563. |
  564. ]])
  565. end)
  566. it('indent-heuristic random order', function()
  567. reread()
  568. feed(':set diffopt=internal,filler,indent-heuristic,algorithm:patience<cr>')
  569. feed(':<cr>')
  570. screen:expect([[
  571. {1: }^def finalize(value│{1: }def finalize(valu|
  572. {1: } │{1: } |
  573. {1: }{2:------------------}│{1: }{4: values.each do }|
  574. {1: }{2:------------------}│{1: }{4: v.prepare }|
  575. {1: }{2:------------------}│{1: }{4: end }|
  576. {1: }{2:------------------}│{1: }{4: }|
  577. {1: } values.each do |│{1: } values.each do |
  578. {1: } v.finalize │{1: } v.finalize |
  579. {1: } end │{1: } end |
  580. {6:~ }│{6:~ }|
  581. {6:~ }│{6:~ }|
  582. {6:~ }│{6:~ }|
  583. {6:~ }│{6:~ }|
  584. {6:~ }│{6:~ }|
  585. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  586. : |
  587. ]])
  588. end)
  589. end)
  590. it('Diff the same file', function()
  591. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  592. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  593. reread()
  594. feed(':set diffopt=filler<cr>')
  595. screen:expect([[
  596. {1:+ }{5:^+-- 10 lines: 1···}│{1:+ }{5:+-- 10 lines: 1··}|
  597. {6:~ }│{6:~ }|
  598. {6:~ }│{6:~ }|
  599. {6:~ }│{6:~ }|
  600. {6:~ }│{6:~ }|
  601. {6:~ }│{6:~ }|
  602. {6:~ }│{6:~ }|
  603. {6:~ }│{6:~ }|
  604. {6:~ }│{6:~ }|
  605. {6:~ }│{6:~ }|
  606. {6:~ }│{6:~ }|
  607. {6:~ }│{6:~ }|
  608. {6:~ }│{6:~ }|
  609. {6:~ }│{6:~ }|
  610. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  611. :set diffopt=filler |
  612. ]])
  613. feed(':set diffopt+=internal<cr>')
  614. screen:expect([[
  615. {1:+ }{5:^+-- 10 lines: 1···}│{1:+ }{5:+-- 10 lines: 1··}|
  616. {6:~ }│{6:~ }|
  617. {6:~ }│{6:~ }|
  618. {6:~ }│{6:~ }|
  619. {6:~ }│{6:~ }|
  620. {6:~ }│{6:~ }|
  621. {6:~ }│{6:~ }|
  622. {6:~ }│{6:~ }|
  623. {6:~ }│{6:~ }|
  624. {6:~ }│{6:~ }|
  625. {6:~ }│{6:~ }|
  626. {6:~ }│{6:~ }|
  627. {6:~ }│{6:~ }|
  628. {6:~ }│{6:~ }|
  629. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  630. :set diffopt+=internal |
  631. ]])
  632. end)
  633. it('Diff an empty file', function()
  634. write_file(fname, "", false)
  635. write_file(fname_2, "", false)
  636. reread()
  637. feed(':set diffopt=filler<cr>')
  638. screen:expect([[
  639. {1:- }^ │{1:- } |
  640. {6:~ }│{6:~ }|
  641. {6:~ }│{6:~ }|
  642. {6:~ }│{6:~ }|
  643. {6:~ }│{6:~ }|
  644. {6:~ }│{6:~ }|
  645. {6:~ }│{6:~ }|
  646. {6:~ }│{6:~ }|
  647. {6:~ }│{6:~ }|
  648. {6:~ }│{6:~ }|
  649. {6:~ }│{6:~ }|
  650. {6:~ }│{6:~ }|
  651. {6:~ }│{6:~ }|
  652. {6:~ }│{6:~ }|
  653. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  654. :set diffopt=filler |
  655. ]])
  656. feed(':set diffopt+=internal<cr>')
  657. screen:expect([[
  658. {1:- }^ │{1:- } |
  659. {6:~ }│{6:~ }|
  660. {6:~ }│{6:~ }|
  661. {6:~ }│{6:~ }|
  662. {6:~ }│{6:~ }|
  663. {6:~ }│{6:~ }|
  664. {6:~ }│{6:~ }|
  665. {6:~ }│{6:~ }|
  666. {6:~ }│{6:~ }|
  667. {6:~ }│{6:~ }|
  668. {6:~ }│{6:~ }|
  669. {6:~ }│{6:~ }|
  670. {6:~ }│{6:~ }|
  671. {6:~ }│{6:~ }|
  672. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  673. :set diffopt+=internal |
  674. ]])
  675. end)
  676. it('diffopt+=icase', function()
  677. write_file(fname, "a\nb\ncd\n", false)
  678. write_file(fname_2, "A\nb\ncDe\n", false)
  679. reread()
  680. feed(':set diffopt=filler,icase<cr>')
  681. screen:expect([[
  682. {1: }^a │{1: }A |
  683. {1: }b │{1: }b |
  684. {1: }{9:cd }│{1: }{9:cD}{8:e}{9: }|
  685. {6:~ }│{6:~ }|
  686. {6:~ }│{6:~ }|
  687. {6:~ }│{6:~ }|
  688. {6:~ }│{6:~ }|
  689. {6:~ }│{6:~ }|
  690. {6:~ }│{6:~ }|
  691. {6:~ }│{6:~ }|
  692. {6:~ }│{6:~ }|
  693. {6:~ }│{6:~ }|
  694. {6:~ }│{6:~ }|
  695. {6:~ }│{6:~ }|
  696. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  697. :set diffopt=filler,icase |
  698. ]])
  699. feed(':set diffopt+=internal<cr>')
  700. screen:expect([[
  701. {1: }^a │{1: }A |
  702. {1: }b │{1: }b |
  703. {1: }{9:cd }│{1: }{9:cD}{8:e}{9: }|
  704. {6:~ }│{6:~ }|
  705. {6:~ }│{6:~ }|
  706. {6:~ }│{6:~ }|
  707. {6:~ }│{6:~ }|
  708. {6:~ }│{6:~ }|
  709. {6:~ }│{6:~ }|
  710. {6:~ }│{6:~ }|
  711. {6:~ }│{6:~ }|
  712. {6:~ }│{6:~ }|
  713. {6:~ }│{6:~ }|
  714. {6:~ }│{6:~ }|
  715. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  716. :set diffopt+=internal |
  717. ]])
  718. end)
  719. describe('diffopt+=iwhite', function()
  720. setup(function()
  721. local f1 = 'int main()\n{\n printf("Hello, World!");\n return 0;\n}\n'
  722. write_file(fname, f1, false)
  723. local f2 = 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n'
  724. write_file(fname_2, f2, false)
  725. feed(':diffupdate!<cr>')
  726. end)
  727. it('external', function()
  728. reread()
  729. feed(':set diffopt=filler,iwhite<cr>')
  730. screen:expect([[
  731. {1: }^int main() │{1: }int main() |
  732. {1: }{ │{1: }{ |
  733. {1: }{2:------------------}│{1: }{4: if (0) }|
  734. {1: }{2:------------------}│{1: }{4: { }|
  735. {1: } printf("Hello, │{1: } printf("Hel|
  736. {1: } return 0; │{1: } return 0; |
  737. {1: }{2:------------------}│{1: }{4: } }|
  738. {1: }} │{1: }} |
  739. {6:~ }│{6:~ }|
  740. {6:~ }│{6:~ }|
  741. {6:~ }│{6:~ }|
  742. {6:~ }│{6:~ }|
  743. {6:~ }│{6:~ }|
  744. {6:~ }│{6:~ }|
  745. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  746. :set diffopt=filler,iwhite |
  747. ]])
  748. end)
  749. it('internal', function()
  750. reread()
  751. feed(':set diffopt=filler,iwhite,internal<cr>')
  752. screen:expect([[
  753. {1: }^int main() │{1: }int main() |
  754. {1: }{ │{1: }{ |
  755. {1: }{2:------------------}│{1: }{4: if (0) }|
  756. {1: }{2:------------------}│{1: }{4: { }|
  757. {1: } printf("Hello, │{1: } printf("Hel|
  758. {1: } return 0; │{1: } return 0; |
  759. {1: }{2:------------------}│{1: }{4: } }|
  760. {1: }} │{1: }} |
  761. {6:~ }│{6:~ }|
  762. {6:~ }│{6:~ }|
  763. {6:~ }│{6:~ }|
  764. {6:~ }│{6:~ }|
  765. {6:~ }│{6:~ }|
  766. {6:~ }│{6:~ }|
  767. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  768. :set diffopt=filler,iwhite,internal |
  769. ]])
  770. end)
  771. end)
  772. describe('diffopt+=iblank', function()
  773. setup(function()
  774. write_file(fname, 'a\n\n \ncd\nef\nxxx\n', false)
  775. write_file(fname_2, 'a\ncd\n\nef\nyyy\n', false)
  776. feed(':diffupdate!<cr>')
  777. end)
  778. it('generic', function()
  779. reread()
  780. feed(':set diffopt=internal,filler,iblank<cr>')
  781. screen:expect([[
  782. {1: }^a │{1: }a |
  783. {1: }{4: }│{1: }{2:-----------------}|
  784. {1: }{4: }│{1: }{2:-----------------}|
  785. {1: }cd │{1: }cd |
  786. {1: }ef │{1: } |
  787. {1: }{8:xxx}{9: }│{1: }ef |
  788. {6:~ }│{1: }{8:yyy}{9: }|
  789. {6:~ }│{6:~ }|
  790. {6:~ }│{6:~ }|
  791. {6:~ }│{6:~ }|
  792. {6:~ }│{6:~ }|
  793. {6:~ }│{6:~ }|
  794. {6:~ }│{6:~ }|
  795. {6:~ }│{6:~ }|
  796. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  797. :set diffopt=internal,filler,iblank |
  798. ]])
  799. end)
  800. it('diffopt+=iwhite', function()
  801. reread()
  802. feed(':set diffopt=internal,filler,iblank,iwhite<cr>')
  803. feed(':<cr>')
  804. screen:expect([[
  805. {1: }^a │{1: }a |
  806. {1: } │{1: }cd |
  807. {1: } │{1: } |
  808. {1: }cd │{1: }ef |
  809. {1: }ef │{1: }{8:yyy}{9: }|
  810. {1: }{8:xxx}{9: }│{6:~ }|
  811. {6:~ }│{6:~ }|
  812. {6:~ }│{6:~ }|
  813. {6:~ }│{6:~ }|
  814. {6:~ }│{6:~ }|
  815. {6:~ }│{6:~ }|
  816. {6:~ }│{6:~ }|
  817. {6:~ }│{6:~ }|
  818. {6:~ }│{6:~ }|
  819. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  820. : |
  821. ]])
  822. end)
  823. it('diffopt+=iwhiteall', function()
  824. reread()
  825. feed(':set diffopt=internal,filler,iblank,iwhiteall<cr>')
  826. feed(':<cr>')
  827. screen:expect([[
  828. {1: }^a │{1: }a |
  829. {1: } │{1: }cd |
  830. {1: } │{1: } |
  831. {1: }cd │{1: }ef |
  832. {1: }ef │{1: }{8:yyy}{9: }|
  833. {1: }{8:xxx}{9: }│{6:~ }|
  834. {6:~ }│{6:~ }|
  835. {6:~ }│{6:~ }|
  836. {6:~ }│{6:~ }|
  837. {6:~ }│{6:~ }|
  838. {6:~ }│{6:~ }|
  839. {6:~ }│{6:~ }|
  840. {6:~ }│{6:~ }|
  841. {6:~ }│{6:~ }|
  842. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  843. : |
  844. ]])
  845. end)
  846. it('diffopt+=iwhiteeol', function()
  847. reread()
  848. feed(':set diffopt=internal,filler,iblank,iwhiteeol<cr>')
  849. feed(':<cr>')
  850. screen:expect([[
  851. {1: }^a │{1: }a |
  852. {1: } │{1: }cd |
  853. {1: } │{1: } |
  854. {1: }cd │{1: }ef |
  855. {1: }ef │{1: }{8:yyy}{9: }|
  856. {1: }{8:xxx}{9: }│{6:~ }|
  857. {6:~ }│{6:~ }|
  858. {6:~ }│{6:~ }|
  859. {6:~ }│{6:~ }|
  860. {6:~ }│{6:~ }|
  861. {6:~ }│{6:~ }|
  862. {6:~ }│{6:~ }|
  863. {6:~ }│{6:~ }|
  864. {6:~ }│{6:~ }|
  865. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  866. : |
  867. ]])
  868. end)
  869. end)
  870. describe('diffopt+=iwhite{eol,all}', function()
  871. setup(function()
  872. write_file(fname, 'a \nx\ncd\nef\nxx xx\nfoo\nbar\n', false)
  873. write_file(fname_2, 'a\nx\nc d\n ef\nxx xx\nfoo\n\nbar\n', false)
  874. feed(':diffupdate!<cr>')
  875. end)
  876. it('diffopt+=iwhiteeol', function()
  877. reread()
  878. feed(':set diffopt=internal,filler,iwhiteeol<cr>')
  879. feed(':<cr>')
  880. screen:expect([[
  881. {1: }^a │{1: }a |
  882. {1: }x │{1: }x |
  883. {1: }{9:cd }│{1: }{9:c}{8: }{9:d }|
  884. {1: }{9:ef }│{1: }{8: }{9:ef }|
  885. {1: }{9:xx }{8: }{9:xx }│{1: }{9:xx xx }|
  886. {1: }foo │{1: }foo |
  887. {1: }{2:------------------}│{1: }{4: }|
  888. {1: }bar │{1: }bar |
  889. {6:~ }│{6:~ }|
  890. {6:~ }│{6:~ }|
  891. {6:~ }│{6:~ }|
  892. {6:~ }│{6:~ }|
  893. {6:~ }│{6:~ }|
  894. {6:~ }│{6:~ }|
  895. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  896. : |
  897. ]])
  898. end)
  899. it('diffopt+=iwhiteall', function()
  900. reread()
  901. feed(':set diffopt=internal,filler,iwhiteall<cr>')
  902. feed(':<cr>')
  903. screen:expect([[
  904. {1: }^a │{1: }a |
  905. {1: }x │{1: }x |
  906. {1: }cd │{1: }c d |
  907. {1: }ef │{1: } ef |
  908. {1: }xx xx │{1: }xx xx |
  909. {1: }foo │{1: }foo |
  910. {1: }{2:------------------}│{1: }{4: }|
  911. {1: }bar │{1: }bar |
  912. {6:~ }│{6:~ }|
  913. {6:~ }│{6:~ }|
  914. {6:~ }│{6:~ }|
  915. {6:~ }│{6:~ }|
  916. {6:~ }│{6:~ }|
  917. {6:~ }│{6:~ }|
  918. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  919. : |
  920. ]])
  921. end)
  922. end)
  923. -- oldtest: Test_diff_scroll()
  924. -- This was scrolling for 'cursorbind' but 'scrollbind' is more important
  925. it('scrolling works correctly vim-patch:8.2.5155', function()
  926. screen:try_resize(40, 12)
  927. write_file(fname, dedent([[
  928. line 1
  929. line 2
  930. line 3
  931. line 4
  932. // Common block
  933. // one
  934. // containing
  935. // four lines
  936. // Common block
  937. // two
  938. // containing
  939. // four lines]]), false)
  940. write_file(fname_2, dedent([[
  941. line 1
  942. line 2
  943. line 3
  944. line 4
  945. Lorem
  946. ipsum
  947. dolor
  948. sit
  949. amet,
  950. consectetur
  951. adipiscing
  952. elit.
  953. Etiam
  954. luctus
  955. lectus
  956. sodales,
  957. dictum
  958. // Common block
  959. // one
  960. // containing
  961. // four lines
  962. Vestibulum
  963. tincidunt
  964. aliquet
  965. nulla.
  966. // Common block
  967. // two
  968. // containing
  969. // four lines]]), false)
  970. reread()
  971. feed('<C-W><C-W>jjjj')
  972. screen:expect([[
  973. {1: }line 1 │{1: }line 1 |
  974. {1: }line 2 │{1: }line 2 |
  975. {1: }line 3 │{1: }line 3 |
  976. {1: }line 4 │{1: }line 4 |
  977. {1: } │{1: }^ |
  978. {1: }{2:-----------------}│{1: }{4:Lorem }|
  979. {1: }{2:-----------------}│{1: }{4:ipsum }|
  980. {1: }{2:-----------------}│{1: }{4:dolor }|
  981. {1: }{2:-----------------}│{1: }{4:sit }|
  982. {1: }{2:-----------------}│{1: }{4:amet, }|
  983. {3:<nal-diff-screen-1 }{7:<al-diff-screen-1.2 }|
  984. :e |
  985. ]])
  986. feed('j')
  987. screen:expect([[
  988. {1: }line 1 │{1: }line 1 |
  989. {1: }line 2 │{1: }line 2 |
  990. {1: }line 3 │{1: }line 3 |
  991. {1: }line 4 │{1: }line 4 |
  992. {1: } │{1: } |
  993. {1: }{2:-----------------}│{1: }{4:^Lorem }|
  994. {1: }{2:-----------------}│{1: }{4:ipsum }|
  995. {1: }{2:-----------------}│{1: }{4:dolor }|
  996. {1: }{2:-----------------}│{1: }{4:sit }|
  997. {1: }{2:-----------------}│{1: }{4:amet, }|
  998. {3:<nal-diff-screen-1 }{7:<al-diff-screen-1.2 }|
  999. :e |
  1000. ]])
  1001. end)
  1002. describe('line matching diff algorithm', function()
  1003. setup(function()
  1004. local f1 = [[if __name__ == "__main__":
  1005. import sys
  1006. app = QWidgets.QApplication(sys.args)
  1007. MainWindow = QtWidgets.QMainWindow()
  1008. ui = UI_MainWindow()
  1009. ui.setupUI(MainWindow)
  1010. MainWindow.show()
  1011. sys.exit(app.exec_())]]
  1012. write_file(fname, f1, false)
  1013. local f2 = [[if __name__ == "__main__":
  1014. import sys
  1015. comment these things
  1016. #app = QWidgets.QApplication(sys.args)
  1017. #MainWindow = QtWidgets.QMainWindow()
  1018. add a completely different line here
  1019. #ui = UI_MainWindow()
  1020. add another new line
  1021. ui.setupUI(MainWindow)
  1022. MainWindow.show()
  1023. sys.exit(app.exec_())]]
  1024. write_file(fname_2, f2, false)
  1025. end)
  1026. it('diffopt+=linematch:20', function()
  1027. reread()
  1028. feed(':set diffopt=internal,filler<cr>')
  1029. screen:expect([[
  1030. {1: }^if __name__ == "__│{1: }if __name__ == "_|
  1031. {1: } import sys │{1: } import sys |
  1032. {1: }{9: }{8:app = QWidgets}│{1: }{9: }{8:comment these}|
  1033. {1: }{9: }{8:MainWindow = Q}│{1: }{9: }{8:#app = QWidge}|
  1034. {1: }{9: }{8:ui = UI_}{9:MainWi}│{1: }{9: }{8:#MainWindow =}|
  1035. {1: }{2:------------------}│{1: }{4: add a complet}|
  1036. {1: }{2:------------------}│{1: }{4: #ui = UI_Main}|
  1037. {1: }{2:------------------}│{1: }{4: add another n}|
  1038. {1: } ui.setupUI(Mai│{1: } ui.setupUI(Ma|
  1039. {1: } MainWindow.sho│{1: } MainWindow.sh|
  1040. {1: } sys.exit(app.e│{1: } sys.exit(app.|
  1041. {6:~ }│{6:~ }|
  1042. {6:~ }│{6:~ }|
  1043. {6:~ }│{6:~ }|
  1044. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  1045. :set diffopt=internal,filler |
  1046. ]])
  1047. feed('G')
  1048. feed(':set diffopt+=linematch:20<cr>')
  1049. screen:expect([[
  1050. {1: }if __name__ == "__│{1: }if __name__ == "_|
  1051. {1: } import sys │{1: } import sys |
  1052. {1: }{2:------------------}│{1: }{4: comment these}|
  1053. {1: }{9: app = QWidgets}│{1: }{9: }{8:#}{9:app = QWidge}|
  1054. {1: }{9: MainWindow = Q}│{1: }{9: }{8:#}{9:MainWindow =}|
  1055. {1: }{2:------------------}│{1: }{4: add a complet}|
  1056. {1: }{9: ui = UI_MainWi}│{1: }{9: }{8:#}{9:ui = UI_Main}|
  1057. {1: }{2:------------------}│{1: }{4: add another n}|
  1058. {1: } ui.setupUI(Mai│{1: } ui.setupUI(Ma|
  1059. {1: } MainWindow.sho│{1: } MainWindow.sh|
  1060. {1: } ^sys.exit(app.e│{1: } sys.exit(app.|
  1061. {6:~ }│{6:~ }|
  1062. {6:~ }│{6:~ }|
  1063. {6:~ }│{6:~ }|
  1064. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  1065. :set diffopt+=linematch:20 |
  1066. ]])
  1067. end)
  1068. end)
  1069. describe('line matching diff algorithm with icase', function()
  1070. setup(function()
  1071. local f1 = [[DDD
  1072. _aa]]
  1073. write_file(fname, f1, false)
  1074. local f2 = [[DDD
  1075. AAA
  1076. ccca]]
  1077. write_file(fname_2, f2, false)
  1078. end)
  1079. it('diffopt+=linematch:20,icase', function()
  1080. reread()
  1081. feed(':set diffopt=internal,filler,linematch:20<cr>')
  1082. screen:expect([[
  1083. {1: }^DDD │{1: }DDD |
  1084. {1: }{2:------------------}│{1: }{4:AAA }|
  1085. {1: }{8:_a}{9:a }│{1: }{8:ccc}{9:a }|
  1086. {6:~ }│{6:~ }|
  1087. {6:~ }│{6:~ }|
  1088. {6:~ }│{6:~ }|
  1089. {6:~ }│{6:~ }|
  1090. {6:~ }│{6:~ }|
  1091. {6:~ }│{6:~ }|
  1092. {6:~ }│{6:~ }|
  1093. {6:~ }│{6:~ }|
  1094. {6:~ }│{6:~ }|
  1095. {6:~ }│{6:~ }|
  1096. {6:~ }│{6:~ }|
  1097. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  1098. |
  1099. ]])
  1100. feed(':set diffopt+=icase<cr>')
  1101. screen:expect([[
  1102. {1: }^DDD │{1: }DDD |
  1103. {1: }{8:_}{9:aa }│{1: }{8:A}{9:AA }|
  1104. {1: }{2:------------------}│{1: }{4:ccca }|
  1105. {6:~ }│{6:~ }|
  1106. {6:~ }│{6:~ }|
  1107. {6:~ }│{6:~ }|
  1108. {6:~ }│{6:~ }|
  1109. {6:~ }│{6:~ }|
  1110. {6:~ }│{6:~ }|
  1111. {6:~ }│{6:~ }|
  1112. {6:~ }│{6:~ }|
  1113. {6:~ }│{6:~ }|
  1114. {6:~ }│{6:~ }|
  1115. {6:~ }│{6:~ }|
  1116. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  1117. :set diffopt+=icase |
  1118. ]])
  1119. end)
  1120. end)
  1121. describe('line matching diff algorithm with iwhiteall', function()
  1122. setup(function()
  1123. local f1 = [[BB
  1124. AAA]]
  1125. write_file(fname, f1, false)
  1126. local f2 = [[BB
  1127. AAB
  1128. AAAB]]
  1129. write_file(fname_2, f2, false)
  1130. end)
  1131. it('diffopt+=linematch:20,iwhiteall', function()
  1132. reread()
  1133. feed(':set diffopt=internal,filler,linematch:20<cr>')
  1134. screen:expect{grid=[[
  1135. {1: }^BB │{1: }BB |
  1136. {1: }{9: AA}{8:A}{9: }│{1: }{9: AA}{8:B}{9: }|
  1137. {1: }{2:------------------}│{1: }{4:AAAB }|
  1138. {6:~ }│{6:~ }|
  1139. {6:~ }│{6:~ }|
  1140. {6:~ }│{6:~ }|
  1141. {6:~ }│{6:~ }|
  1142. {6:~ }│{6:~ }|
  1143. {6:~ }│{6:~ }|
  1144. {6:~ }│{6:~ }|
  1145. {6:~ }│{6:~ }|
  1146. {6:~ }│{6:~ }|
  1147. {6:~ }│{6:~ }|
  1148. {6:~ }│{6:~ }|
  1149. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  1150. |
  1151. ]]}
  1152. feed(':set diffopt+=iwhiteall<cr>')
  1153. screen:expect{grid=[[
  1154. {1: }^BB │{1: }BB |
  1155. {1: }{2:------------------}│{1: }{4: AAB }|
  1156. {1: }{9: AAA }│{1: }{9:AAA}{8:B}{9: }|
  1157. {6:~ }│{6:~ }|
  1158. {6:~ }│{6:~ }|
  1159. {6:~ }│{6:~ }|
  1160. {6:~ }│{6:~ }|
  1161. {6:~ }│{6:~ }|
  1162. {6:~ }│{6:~ }|
  1163. {6:~ }│{6:~ }|
  1164. {6:~ }│{6:~ }|
  1165. {6:~ }│{6:~ }|
  1166. {6:~ }│{6:~ }|
  1167. {6:~ }│{6:~ }|
  1168. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  1169. :set diffopt+=iwhiteall |
  1170. ]]}
  1171. end)
  1172. end)
  1173. end)
  1174. it('win_update redraws lines properly', function()
  1175. local screen
  1176. screen = Screen.new(50, 10)
  1177. screen:attach()
  1178. screen:set_default_attr_ids({
  1179. [1] = {bold = true, foreground = Screen.colors.Blue1},
  1180. [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  1181. [3] = {background = Screen.colors.Red, foreground = Screen.colors.Grey100, special = Screen.colors.Yellow},
  1182. [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
  1183. [5] = {special = Screen.colors.Yellow},
  1184. [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4},
  1185. [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100},
  1186. [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100},
  1187. [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100},
  1188. [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')},
  1189. [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452')},
  1190. [12] = {bold = true, reverse = true},
  1191. [13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  1192. [14] = {reverse = true},
  1193. [15] = {background = Screen.colors.LightBlue},
  1194. [16] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
  1195. [17] = {bold = true, background = Screen.colors.Red},
  1196. [18] = {background = Screen.colors.LightMagenta},
  1197. })
  1198. insert([[
  1199. 1
  1200. 2
  1201. 1a
  1202. ]])
  1203. command("vnew left")
  1204. insert([[
  1205. 2
  1206. 2a
  1207. 2b
  1208. ]])
  1209. command("windo diffthis")
  1210. command("windo 1")
  1211. screen:expect{grid=[[
  1212. {13: }{16:-----------------------}│{13: }{15:^1 }|
  1213. {13: }{16:-----------------------}│{13: }{15: }|
  1214. {13: }{16:-----------------------}│{13: }{15: }|
  1215. {13: }2 │{13: }2 |
  1216. {13: }{17:2}{18:a }│{13: }{17:1}{18:a }|
  1217. {13: }{15:2b }│{13: }{16:----------------------}|
  1218. {13: } │{13: } |
  1219. {1:~ }│{1:~ }|
  1220. {14:left [+] }{12:[No Name] [+] }|
  1221. |
  1222. ]]}
  1223. feed('<C-e>')
  1224. feed('<C-e>')
  1225. feed('<C-y>')
  1226. feed('<C-y>')
  1227. feed('<C-y>')
  1228. screen:expect{grid=[[
  1229. {13: }{16:-----------------------}│{13: }{15:1 }|
  1230. {13: }{16:-----------------------}│{13: }{15: }|
  1231. {13: }{16:-----------------------}│{13: }{15:^ }|
  1232. {13: }2 │{13: }2 |
  1233. {13: }{17:2}{18:a }│{13: }{17:1}{18:a }|
  1234. {13: }{15:2b }│{13: }{16:----------------------}|
  1235. {13: } │{13: } |
  1236. {1:~ }│{1:~ }|
  1237. {14:left [+] }{12:[No Name] [+] }|
  1238. |
  1239. ]]}
  1240. end)
  1241. -- oldtest: Test_diff_rnu()
  1242. it('diff updates line numbers below filler lines', function()
  1243. local screen = Screen.new(40, 14)
  1244. screen:attach()
  1245. screen:set_default_attr_ids({
  1246. [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  1247. [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
  1248. [3] = {reverse = true},
  1249. [4] = {background = Screen.colors.LightBlue},
  1250. [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
  1251. [6] = {bold = true, foreground = Screen.colors.Blue1},
  1252. [7] = {bold = true, reverse = true},
  1253. [8] = {bold = true, background = Screen.colors.Red},
  1254. [9] = {background = Screen.colors.LightMagenta},
  1255. [10] = {bold = true, foreground = Screen.colors.Brown},
  1256. [11] = {foreground = Screen.colors.Brown},
  1257. })
  1258. exec([[
  1259. call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
  1260. vnew
  1261. call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
  1262. windo diffthis
  1263. setlocal number rnu cursorline cursorlineopt=number foldcolumn=0
  1264. ]])
  1265. screen:expect([[
  1266. {1: }a │{10:1 }^a |
  1267. {1: }a │{11: 1 }a |
  1268. {1: }a │{11: 2 }a |
  1269. {1: }{8:x}{9: }│{11: 3 }{8:y}{9: }|
  1270. {1: }{4:x }│{11: }{2:----------------}|
  1271. {1: }{4:x }│{11: }{2:----------------}|
  1272. {1: }b │{11: 4 }b |
  1273. {1: }b │{11: 5 }b |
  1274. {1: }b │{11: 6 }b |
  1275. {1: }b │{11: 7 }b |
  1276. {1: }b │{11: 8 }b |
  1277. {6:~ }│{6:~ }|
  1278. {3:[No Name] [+] }{7:[No Name] [+] }|
  1279. |
  1280. ]])
  1281. feed('j')
  1282. screen:expect([[
  1283. {1: }a │{11: 1 }a |
  1284. {1: }a │{10:2 }^a |
  1285. {1: }a │{11: 1 }a |
  1286. {1: }{8:x}{9: }│{11: 2 }{8:y}{9: }|
  1287. {1: }{4:x }│{11: }{2:----------------}|
  1288. {1: }{4:x }│{11: }{2:----------------}|
  1289. {1: }b │{11: 3 }b |
  1290. {1: }b │{11: 4 }b |
  1291. {1: }b │{11: 5 }b |
  1292. {1: }b │{11: 6 }b |
  1293. {1: }b │{11: 7 }b |
  1294. {6:~ }│{6:~ }|
  1295. {3:[No Name] [+] }{7:[No Name] [+] }|
  1296. |
  1297. ]])
  1298. feed('j')
  1299. screen:expect([[
  1300. {1: }a │{11: 2 }a |
  1301. {1: }a │{11: 1 }a |
  1302. {1: }a │{10:3 }^a |
  1303. {1: }{8:x}{9: }│{11: 1 }{8:y}{9: }|
  1304. {1: }{4:x }│{11: }{2:----------------}|
  1305. {1: }{4:x }│{11: }{2:----------------}|
  1306. {1: }b │{11: 2 }b |
  1307. {1: }b │{11: 3 }b |
  1308. {1: }b │{11: 4 }b |
  1309. {1: }b │{11: 5 }b |
  1310. {1: }b │{11: 6 }b |
  1311. {6:~ }│{6:~ }|
  1312. {3:[No Name] [+] }{7:[No Name] [+] }|
  1313. |
  1314. ]])
  1315. end)
  1316. -- oldtest: Test_diff_with_scroll_and_change()
  1317. it('Align the filler lines when changing text in diff mode', function()
  1318. local screen = Screen.new(40, 20)
  1319. screen:attach()
  1320. screen:set_default_attr_ids({
  1321. [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
  1322. [2] = {background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1, bold = true};
  1323. [3] = {reverse = true};
  1324. [4] = {background = Screen.colors.LightBlue};
  1325. [5] = {background = Screen.colors.LightMagenta};
  1326. [6] = {background = Screen.colors.Red, bold = true};
  1327. [7] = {foreground = Screen.colors.Blue1, bold = true};
  1328. [8] = {reverse = true, bold = true};
  1329. })
  1330. exec([[
  1331. call setline(1, range(1, 15))
  1332. vnew
  1333. call setline(1, range(9, 15))
  1334. windo diffthis
  1335. wincmd h
  1336. exe "normal Gl5\<C-E>"
  1337. ]])
  1338. screen:expect{grid=[[
  1339. {1: }{2:------------------}│{1: }{4:6 }|
  1340. {1: }{2:------------------}│{1: }{4:7 }|
  1341. {1: }{2:------------------}│{1: }{4:8 }|
  1342. {1: }9 │{1: }9 |
  1343. {1: }10 │{1: }10 |
  1344. {1: }11 │{1: }11 |
  1345. {1: }12 │{1: }12 |
  1346. {1: }13 │{1: }13 |
  1347. {1: }14 │{1: }14 |
  1348. {1:- }1^5 │{1:- }15 |
  1349. {7:~ }│{7:~ }|
  1350. {7:~ }│{7:~ }|
  1351. {7:~ }│{7:~ }|
  1352. {7:~ }│{7:~ }|
  1353. {7:~ }│{7:~ }|
  1354. {7:~ }│{7:~ }|
  1355. {7:~ }│{7:~ }|
  1356. {7:~ }│{7:~ }|
  1357. {8:[No Name] [+] }{3:[No Name] [+] }|
  1358. |
  1359. ]]}
  1360. feed('ax<Esc>')
  1361. screen:expect{grid=[[
  1362. {1: }{2:------------------}│{1: }{4:6 }|
  1363. {1: }{2:------------------}│{1: }{4:7 }|
  1364. {1: }{2:------------------}│{1: }{4:8 }|
  1365. {1: }9 │{1: }9 |
  1366. {1: }10 │{1: }10 |
  1367. {1: }11 │{1: }11 |
  1368. {1: }12 │{1: }12 |
  1369. {1: }13 │{1: }13 |
  1370. {1: }14 │{1: }14 |
  1371. {1: }{5:15}{6:^x}{5: }│{1: }{5:15 }|
  1372. {7:~ }│{7:~ }|
  1373. {7:~ }│{7:~ }|
  1374. {7:~ }│{7:~ }|
  1375. {7:~ }│{7:~ }|
  1376. {7:~ }│{7:~ }|
  1377. {7:~ }│{7:~ }|
  1378. {7:~ }│{7:~ }|
  1379. {7:~ }│{7:~ }|
  1380. {8:[No Name] [+] }{3:[No Name] [+] }|
  1381. |
  1382. ]]}
  1383. feed('<C-W>lay<Esc>')
  1384. screen:expect{grid=[[
  1385. {1: }{2:-----------------}│{1: }{4:6 }|
  1386. {1: }{2:-----------------}│{1: }{4:7 }|
  1387. {1: }{2:-----------------}│{1: }{4:8 }|
  1388. {1: }9 │{1: }9 |
  1389. {1: }10 │{1: }10 |
  1390. {1: }11 │{1: }11 |
  1391. {1: }12 │{1: }12 |
  1392. {1: }13 │{1: }13 |
  1393. {1: }14 │{1: }14 |
  1394. {1: }{5:15}{6:x}{5: }│{1: }{5:15}{6:^y}{5: }|
  1395. {7:~ }│{7:~ }|
  1396. {7:~ }│{7:~ }|
  1397. {7:~ }│{7:~ }|
  1398. {7:~ }│{7:~ }|
  1399. {7:~ }│{7:~ }|
  1400. {7:~ }│{7:~ }|
  1401. {7:~ }│{7:~ }|
  1402. {7:~ }│{7:~ }|
  1403. {3:[No Name] [+] }{8:[No Name] [+] }|
  1404. |
  1405. ]]}
  1406. end)
  1407. it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function()
  1408. local screen = Screen.new(60, 6)
  1409. screen:set_default_attr_ids({
  1410. [0] = {foreground = Screen.colors.Blue, bold = true};
  1411. })
  1412. screen:attach()
  1413. eq('0', meths.get_option_value('foldcolumn', {}))
  1414. command('diffsplit | bd')
  1415. screen:expect([[
  1416. ^ |
  1417. {0:~ }|
  1418. {0:~ }|
  1419. {0:~ }|
  1420. {0:~ }|
  1421. |
  1422. ]])
  1423. eq('0', meths.get_option_value('foldcolumn', {}))
  1424. end)
  1425. -- oldtest: Test_diff_binary()
  1426. it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
  1427. local screen = Screen.new(40, 20)
  1428. screen:set_default_attr_ids({
  1429. [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
  1430. [2] = {reverse = true};
  1431. [3] = {background = Screen.colors.LightBlue};
  1432. [4] = {background = Screen.colors.LightMagenta};
  1433. [5] = {background = Screen.colors.Red, bold = true};
  1434. [6] = {foreground = Screen.colors.Blue, bold = true};
  1435. [7] = {background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true};
  1436. [8] = {reverse = true, bold = true};
  1437. })
  1438. screen:attach()
  1439. exec([[
  1440. call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g'])
  1441. vnew
  1442. call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g'])
  1443. windo diffthis
  1444. wincmd p
  1445. norm! gg0
  1446. redraw!
  1447. ]])
  1448. -- Test using internal diff
  1449. screen:expect([[
  1450. {1: }{5:^A}{4: }│{1: }{5:a}{4: }|
  1451. {1: }b │{1: }b |
  1452. {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
  1453. {1: }d │{1: }d |
  1454. {1: }{5:E}{4: }│{1: }{5:e}{4: }|
  1455. {1: }f │{1: }f |
  1456. {1: }g │{1: }g |
  1457. {6:~ }│{6:~ }|
  1458. {6:~ }│{6:~ }|
  1459. {6:~ }│{6:~ }|
  1460. {6:~ }│{6:~ }|
  1461. {6:~ }│{6:~ }|
  1462. {6:~ }│{6:~ }|
  1463. {6:~ }│{6:~ }|
  1464. {6:~ }│{6:~ }|
  1465. {6:~ }│{6:~ }|
  1466. {6:~ }│{6:~ }|
  1467. {6:~ }│{6:~ }|
  1468. {8:[No Name] [+] }{2:[No Name] [+] }|
  1469. |
  1470. ]])
  1471. -- Test using internal diff and case folding
  1472. command('set diffopt+=icase')
  1473. feed('<C-L>')
  1474. screen:expect([[
  1475. {1: }^A │{1: }a |
  1476. {1: }b │{1: }b |
  1477. {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
  1478. {1: }d │{1: }d |
  1479. {1: }E │{1: }e |
  1480. {1: }f │{1: }f |
  1481. {1: }g │{1: }g |
  1482. {6:~ }│{6:~ }|
  1483. {6:~ }│{6:~ }|
  1484. {6:~ }│{6:~ }|
  1485. {6:~ }│{6:~ }|
  1486. {6:~ }│{6:~ }|
  1487. {6:~ }│{6:~ }|
  1488. {6:~ }│{6:~ }|
  1489. {6:~ }│{6:~ }|
  1490. {6:~ }│{6:~ }|
  1491. {6:~ }│{6:~ }|
  1492. {6:~ }│{6:~ }|
  1493. {8:[No Name] [+] }{2:[No Name] [+] }|
  1494. |
  1495. ]])
  1496. -- Test using external diff
  1497. command('set diffopt=filler')
  1498. feed('<C-L>')
  1499. screen:expect([[
  1500. {1: }{5:^A}{4: }│{1: }{5:a}{4: }|
  1501. {1: }b │{1: }b |
  1502. {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
  1503. {1: }d │{1: }d |
  1504. {1: }{5:E}{4: }│{1: }{5:e}{4: }|
  1505. {1: }f │{1: }f |
  1506. {1: }g │{1: }g |
  1507. {6:~ }│{6:~ }|
  1508. {6:~ }│{6:~ }|
  1509. {6:~ }│{6:~ }|
  1510. {6:~ }│{6:~ }|
  1511. {6:~ }│{6:~ }|
  1512. {6:~ }│{6:~ }|
  1513. {6:~ }│{6:~ }|
  1514. {6:~ }│{6:~ }|
  1515. {6:~ }│{6:~ }|
  1516. {6:~ }│{6:~ }|
  1517. {6:~ }│{6:~ }|
  1518. {8:[No Name] [+] }{2:[No Name] [+] }|
  1519. |
  1520. ]])
  1521. -- Test using external diff and case folding
  1522. command('set diffopt+=filler,icase')
  1523. feed('<C-L>')
  1524. screen:expect([[
  1525. {1: }^A │{1: }a |
  1526. {1: }b │{1: }b |
  1527. {1: }{4:c }│{1: }{4:c}{7:^@}{4: }|
  1528. {1: }d │{1: }d |
  1529. {1: }E │{1: }e |
  1530. {1: }f │{1: }f |
  1531. {1: }g │{1: }g |
  1532. {6:~ }│{6:~ }|
  1533. {6:~ }│{6:~ }|
  1534. {6:~ }│{6:~ }|
  1535. {6:~ }│{6:~ }|
  1536. {6:~ }│{6:~ }|
  1537. {6:~ }│{6:~ }|
  1538. {6:~ }│{6:~ }|
  1539. {6:~ }│{6:~ }|
  1540. {6:~ }│{6:~ }|
  1541. {6:~ }│{6:~ }|
  1542. {6:~ }│{6:~ }|
  1543. {8:[No Name] [+] }{2:[No Name] [+] }|
  1544. |
  1545. ]])
  1546. end)
  1547. -- oldtest: Test_diff_breakindent_after_filler()
  1548. it("diff mode draws 'breakindent' correctly after filler lines", function()
  1549. local screen = Screen.new(45, 8)
  1550. screen:attach()
  1551. screen:set_default_attr_ids({
  1552. [1] = {background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue};
  1553. [2] = {background = Screen.colors.LightBlue};
  1554. [3] = {background = Screen.colors.LightCyan, bold = true, foreground = Screen.colors.Blue};
  1555. [4] = {foreground = Screen.colors.Blue, bold = true};
  1556. })
  1557. exec([[
  1558. set laststatus=0 diffopt+=followwrap breakindent
  1559. call setline(1, ['a', ' ' .. repeat('c', 50)])
  1560. vnew
  1561. call setline(1, ['a', 'b', ' ' .. repeat('c', 50)])
  1562. windo diffthis
  1563. norm! G$
  1564. ]])
  1565. screen:expect([[
  1566. {1: }a │{1: }a |
  1567. {1: }{2:b }│{1: }{3:--------------------}|
  1568. {1: } cccccccccccccccccc│{1: } cccccccccccccccccc|
  1569. {1: } cccccccccccccccccc│{1: } cccccccccccccccccc|
  1570. {1: } cccccccccccccc │{1: } ccccccccccccc^c |
  1571. {4:~ }│{4:~ }|
  1572. {4:~ }│{4:~ }|
  1573. |
  1574. ]])
  1575. end)