diff_spec.lua 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  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 write_file = helpers.write_file
  6. describe('Diff mode screen', function()
  7. local fname = 'Xtest-functional-diff-screen-1'
  8. local fname_2 = fname .. '.2'
  9. local screen
  10. local reread = function()
  11. feed(':e<cr><c-w>w:e<cr><c-w>w')
  12. end
  13. setup(function()
  14. clear()
  15. os.remove(fname)
  16. os.remove(fname_2)
  17. end)
  18. teardown(function()
  19. os.remove(fname)
  20. os.remove(fname_2)
  21. end)
  22. before_each(function()
  23. clear()
  24. feed(':e ' .. fname_2 .. '<cr>')
  25. feed(':vnew ' .. fname .. '<cr>')
  26. feed(':diffthis<cr>')
  27. feed('<c-w>w:diffthis<cr><c-w>w')
  28. screen = Screen.new(40, 16)
  29. screen:attach()
  30. screen:set_default_attr_ids({
  31. [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  32. [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
  33. [3] = {reverse = true},
  34. [4] = {background = Screen.colors.LightBlue},
  35. [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey},
  36. [6] = {bold = true, foreground = Screen.colors.Blue1},
  37. [7] = {bold = true, reverse = true},
  38. [8] = {bold = true, background = Screen.colors.Red},
  39. [9] = {background = Screen.colors.LightMagenta},
  40. })
  41. end)
  42. it('Add a line in beginning of file 2', function()
  43. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  44. write_file(fname_2, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  45. reread()
  46. feed(':set diffopt=filler<cr>')
  47. screen:expect([[
  48. {1: }{2:------------------}{3:│}{1: }{4:0 }|
  49. {1: }^1 {3:│}{1: }1 |
  50. {1: }2 {3:│}{1: }2 |
  51. {1: }3 {3:│}{1: }3 |
  52. {1: }4 {3:│}{1: }4 |
  53. {1: }5 {3:│}{1: }5 |
  54. {1: }6 {3:│}{1: }6 |
  55. {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
  56. {1: }{6:~ }{3:│}{1: }{6:~ }|
  57. {1: }{6:~ }{3:│}{1: }{6:~ }|
  58. {1: }{6:~ }{3:│}{1: }{6:~ }|
  59. {1: }{6:~ }{3:│}{1: }{6:~ }|
  60. {1: }{6:~ }{3:│}{1: }{6:~ }|
  61. {1: }{6:~ }{3:│}{1: }{6:~ }|
  62. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  63. :set diffopt=filler |
  64. ]])
  65. feed(':set diffopt+=internal<cr>')
  66. screen:expect([[
  67. {1: }{2:------------------}{3:│}{1: }{4:0 }|
  68. {1: }^1 {3:│}{1: }1 |
  69. {1: }2 {3:│}{1: }2 |
  70. {1: }3 {3:│}{1: }3 |
  71. {1: }4 {3:│}{1: }4 |
  72. {1: }5 {3:│}{1: }5 |
  73. {1: }6 {3:│}{1: }6 |
  74. {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
  75. {1: }{6:~ }{3:│}{1: }{6:~ }|
  76. {1: }{6:~ }{3:│}{1: }{6:~ }|
  77. {1: }{6:~ }{3:│}{1: }{6:~ }|
  78. {1: }{6:~ }{3:│}{1: }{6:~ }|
  79. {1: }{6:~ }{3:│}{1: }{6:~ }|
  80. {1: }{6:~ }{3:│}{1: }{6:~ }|
  81. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  82. :set diffopt+=internal |
  83. ]])
  84. end)
  85. it('Add a line in beginning of file 1', function()
  86. write_file(fname, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  87. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  88. reread()
  89. feed(":set diffopt=filler<cr>")
  90. screen:expect([[
  91. {1: }{4:^0 }{3:│}{1: }{2:-----------------}|
  92. {1: }1 {3:│}{1: }1 |
  93. {1: }2 {3:│}{1: }2 |
  94. {1: }3 {3:│}{1: }3 |
  95. {1: }4 {3:│}{1: }4 |
  96. {1: }5 {3:│}{1: }5 |
  97. {1: }6 {3:│}{1: }6 |
  98. {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
  99. {1: }{6:~ }{3:│}{1: }{6:~ }|
  100. {1: }{6:~ }{3:│}{1: }{6:~ }|
  101. {1: }{6:~ }{3:│}{1: }{6:~ }|
  102. {1: }{6:~ }{3:│}{1: }{6:~ }|
  103. {1: }{6:~ }{3:│}{1: }{6:~ }|
  104. {1: }{6:~ }{3:│}{1: }{6:~ }|
  105. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  106. :set diffopt=filler |
  107. ]])
  108. feed(":set diffopt+=internal<cr>")
  109. screen:expect([[
  110. {1: }{4:^0 }{3:│}{1: }{2:-----------------}|
  111. {1: }1 {3:│}{1: }1 |
  112. {1: }2 {3:│}{1: }2 |
  113. {1: }3 {3:│}{1: }3 |
  114. {1: }4 {3:│}{1: }4 |
  115. {1: }5 {3:│}{1: }5 |
  116. {1: }6 {3:│}{1: }6 |
  117. {1:+ }{5:+-- 4 lines: 7···}{3:│}{1:+ }{5:+-- 4 lines: 7··}|
  118. {1: }{6:~ }{3:│}{1: }{6:~ }|
  119. {1: }{6:~ }{3:│}{1: }{6:~ }|
  120. {1: }{6:~ }{3:│}{1: }{6:~ }|
  121. {1: }{6:~ }{3:│}{1: }{6:~ }|
  122. {1: }{6:~ }{3:│}{1: }{6:~ }|
  123. {1: }{6:~ }{3:│}{1: }{6:~ }|
  124. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  125. :set diffopt+=internal |
  126. ]])
  127. end)
  128. it('Add a line at the end of file 2', function()
  129. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  130. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  131. reread()
  132. feed(":set diffopt=filler<cr>")
  133. screen:expect([[
  134. {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
  135. {1: }5 {3:│}{1: }5 |
  136. {1: }6 {3:│}{1: }6 |
  137. {1: }7 {3:│}{1: }7 |
  138. {1: }8 {3:│}{1: }8 |
  139. {1: }9 {3:│}{1: }9 |
  140. {1: }10 {3:│}{1: }10 |
  141. {1: }{2:------------------}{3:│}{1: }{4:11 }|
  142. {1: }{6:~ }{3:│}{1: }{6:~ }|
  143. {1: }{6:~ }{3:│}{1: }{6:~ }|
  144. {1: }{6:~ }{3:│}{1: }{6:~ }|
  145. {1: }{6:~ }{3:│}{1: }{6:~ }|
  146. {1: }{6:~ }{3:│}{1: }{6:~ }|
  147. {1: }{6:~ }{3:│}{1: }{6:~ }|
  148. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  149. :set diffopt=filler |
  150. ]])
  151. feed(":set diffopt+=internal<cr>")
  152. screen:expect([[
  153. {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
  154. {1: }5 {3:│}{1: }5 |
  155. {1: }6 {3:│}{1: }6 |
  156. {1: }7 {3:│}{1: }7 |
  157. {1: }8 {3:│}{1: }8 |
  158. {1: }9 {3:│}{1: }9 |
  159. {1: }10 {3:│}{1: }10 |
  160. {1: }{2:------------------}{3:│}{1: }{4:11 }|
  161. {1: }{6:~ }{3:│}{1: }{6:~ }|
  162. {1: }{6:~ }{3:│}{1: }{6:~ }|
  163. {1: }{6:~ }{3:│}{1: }{6:~ }|
  164. {1: }{6:~ }{3:│}{1: }{6:~ }|
  165. {1: }{6:~ }{3:│}{1: }{6:~ }|
  166. {1: }{6:~ }{3:│}{1: }{6:~ }|
  167. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  168. :set diffopt+=internal |
  169. ]])
  170. end)
  171. it('Add a line at the end of file 1', function()
  172. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  173. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  174. reread()
  175. feed(":set diffopt=filler<cr>")
  176. screen:expect([[
  177. {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
  178. {1: }5 {3:│}{1: }5 |
  179. {1: }6 {3:│}{1: }6 |
  180. {1: }7 {3:│}{1: }7 |
  181. {1: }8 {3:│}{1: }8 |
  182. {1: }9 {3:│}{1: }9 |
  183. {1: }10 {3:│}{1: }10 |
  184. {1: }{4:11 }{3:│}{1: }{2:-----------------}|
  185. {1: }{6:~ }{3:│}{1: }{6:~ }|
  186. {1: }{6:~ }{3:│}{1: }{6:~ }|
  187. {1: }{6:~ }{3:│}{1: }{6:~ }|
  188. {1: }{6:~ }{3:│}{1: }{6:~ }|
  189. {1: }{6:~ }{3:│}{1: }{6:~ }|
  190. {1: }{6:~ }{3:│}{1: }{6:~ }|
  191. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  192. :set diffopt=filler |
  193. ]])
  194. feed(":set diffopt+=internal<cr>")
  195. screen:expect([[
  196. {1:+ }{5:^+-- 4 lines: 1···}{3:│}{1:+ }{5:+-- 4 lines: 1··}|
  197. {1: }5 {3:│}{1: }5 |
  198. {1: }6 {3:│}{1: }6 |
  199. {1: }7 {3:│}{1: }7 |
  200. {1: }8 {3:│}{1: }8 |
  201. {1: }9 {3:│}{1: }9 |
  202. {1: }10 {3:│}{1: }10 |
  203. {1: }{4:11 }{3:│}{1: }{2:-----------------}|
  204. {1: }{6:~ }{3:│}{1: }{6:~ }|
  205. {1: }{6:~ }{3:│}{1: }{6:~ }|
  206. {1: }{6:~ }{3:│}{1: }{6:~ }|
  207. {1: }{6:~ }{3:│}{1: }{6:~ }|
  208. {1: }{6:~ }{3:│}{1: }{6:~ }|
  209. {1: }{6:~ }{3:│}{1: }{6:~ }|
  210. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  211. :set diffopt+=internal |
  212. ]])
  213. end)
  214. it('Add a line in the middle of file 2, remove on at the end of file 1', function()
  215. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  216. write_file(fname_2, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
  217. reread()
  218. feed(':set diffopt=filler<cr>')
  219. screen:expect([[
  220. {1: }^1 {3:│}{1: }1 |
  221. {1: }2 {3:│}{1: }2 |
  222. {1: }3 {3:│}{1: }3 |
  223. {1: }4 {3:│}{1: }4 |
  224. {1: }{2:------------------}{3:│}{1: }{4:4 }|
  225. {1: }5 {3:│}{1: }5 |
  226. {1: }6 {3:│}{1: }6 |
  227. {1: }7 {3:│}{1: }7 |
  228. {1: }8 {3:│}{1: }8 |
  229. {1: }9 {3:│}{1: }9 |
  230. {1: }10 {3:│}{1: }10 |
  231. {1: }{4:11 }{3:│}{1: }{2:-----------------}|
  232. {1: }{6:~ }{3:│}{1: }{6:~ }|
  233. {1: }{6:~ }{3:│}{1: }{6:~ }|
  234. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  235. :set diffopt=filler |
  236. ]])
  237. feed(':set diffopt+=internal<cr>')
  238. screen:expect([[
  239. {1: }^1 {3:│}{1: }1 |
  240. {1: }2 {3:│}{1: }2 |
  241. {1: }3 {3:│}{1: }3 |
  242. {1: }4 {3:│}{1: }4 |
  243. {1: }{2:------------------}{3:│}{1: }{4:4 }|
  244. {1: }5 {3:│}{1: }5 |
  245. {1: }6 {3:│}{1: }6 |
  246. {1: }7 {3:│}{1: }7 |
  247. {1: }8 {3:│}{1: }8 |
  248. {1: }9 {3:│}{1: }9 |
  249. {1: }10 {3:│}{1: }10 |
  250. {1: }{4:11 }{3:│}{1: }{2:-----------------}|
  251. {1: }{6:~ }{3:│}{1: }{6:~ }|
  252. {1: }{6:~ }{3:│}{1: }{6:~ }|
  253. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  254. :set diffopt+=internal |
  255. ]])
  256. end)
  257. it('Add a line in the middle of file 1, remove on at the end of file 2', function()
  258. write_file(fname, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false)
  259. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false)
  260. reread()
  261. feed(':set diffopt=filler<cr>')
  262. screen:expect([[
  263. {1: }^1 {3:│}{1: }1 |
  264. {1: }2 {3:│}{1: }2 |
  265. {1: }3 {3:│}{1: }3 |
  266. {1: }4 {3:│}{1: }4 |
  267. {1: }{4:4 }{3:│}{1: }{2:-----------------}|
  268. {1: }5 {3:│}{1: }5 |
  269. {1: }6 {3:│}{1: }6 |
  270. {1: }7 {3:│}{1: }7 |
  271. {1: }8 {3:│}{1: }8 |
  272. {1: }9 {3:│}{1: }9 |
  273. {1: }10 {3:│}{1: }10 |
  274. {1: }{2:------------------}{3:│}{1: }{4:11 }|
  275. {1: }{6:~ }{3:│}{1: }{6:~ }|
  276. {1: }{6:~ }{3:│}{1: }{6:~ }|
  277. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  278. :set diffopt=filler |
  279. ]])
  280. feed(':set diffopt+=internal<cr>')
  281. screen:expect([[
  282. {1: }^1 {3:│}{1: }1 |
  283. {1: }2 {3:│}{1: }2 |
  284. {1: }3 {3:│}{1: }3 |
  285. {1: }4 {3:│}{1: }4 |
  286. {1: }{4:4 }{3:│}{1: }{2:-----------------}|
  287. {1: }5 {3:│}{1: }5 |
  288. {1: }6 {3:│}{1: }6 |
  289. {1: }7 {3:│}{1: }7 |
  290. {1: }8 {3:│}{1: }8 |
  291. {1: }9 {3:│}{1: }9 |
  292. {1: }10 {3:│}{1: }10 |
  293. {1: }{2:------------------}{3:│}{1: }{4:11 }|
  294. {1: }{6:~ }{3:│}{1: }{6:~ }|
  295. {1: }{6:~ }{3:│}{1: }{6:~ }|
  296. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  297. :set diffopt+=internal |
  298. ]])
  299. end)
  300. describe('normal/patience/histogram diff algorithm', function()
  301. setup(function()
  302. local f1 = [[#include <stdio.h>
  303. // Frobs foo heartily
  304. int frobnitz(int foo)
  305. {
  306. int i;
  307. for(i = 0; i < 10; i++)
  308. {
  309. printf("Your answer is: ");
  310. printf("%d\n", foo);
  311. }
  312. }
  313. int fact(int n)
  314. {
  315. if(n > 1)
  316. {
  317. return fact(n-1) * n;
  318. }
  319. return 1;
  320. }
  321. int main(int argc, char **argv)
  322. {
  323. frobnitz(fact(10));
  324. }]]
  325. write_file(fname, f1, false)
  326. local f2 = [[#include <stdio.h>
  327. int fib(int n)
  328. {
  329. if(n > 2)
  330. {
  331. return fib(n-1) + fib(n-2);
  332. }
  333. return 1;
  334. }
  335. // Frobs foo heartily
  336. int frobnitz(int foo)
  337. {
  338. int i;
  339. for(i = 0; i < 10; i++)
  340. {
  341. printf("%d\n", foo);
  342. }
  343. }
  344. int main(int argc, char **argv)
  345. {
  346. frobnitz(fib(10));
  347. }]]
  348. write_file(fname_2, f2, false)
  349. end)
  350. it('diffopt=+algorithm:myers', function()
  351. reread()
  352. feed(':set diffopt=internal,filler<cr>')
  353. screen:expect([[
  354. {1: }^#include <stdio.h>{3:│}{1: }#include <stdio.h|
  355. {1: } {3:│}{1: } |
  356. {1: }{8:// Frobs foo heart}{3:│}{1: }{8:int fib(int n)}{9: }|
  357. {1: }{4:int frobnitz(int f}{3:│}{1: }{2:-----------------}|
  358. {1: }{ {3:│}{1: }{ |
  359. {1: }{9: i}{8:nt i;}{9: }{3:│}{1: }{9: i}{8:f(n > 2)}{9: }|
  360. {1: }{4: for(i = 0; i <}{3:│}{1: }{2:-----------------}|
  361. {1: } { {3:│}{1: } { |
  362. {1: }{9: }{8:printf("Yo}{3:│}{1: }{9: }{8:return fi}|
  363. {1: }{4: printf("%d}{3:│}{1: }{2:-----------------}|
  364. {1: } } {3:│}{1: } } |
  365. {1: }{2:------------------}{3:│}{1: }{4: return 1; }|
  366. {1: }} {3:│}{1: }} |
  367. {1: } {3:│}{1: } |
  368. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  369. :set diffopt=internal,filler |
  370. ]])
  371. feed('G')
  372. screen:expect([[
  373. {1: }{2:------------------}{3:│}{1: }{4:int frobnitz(int }|
  374. {1: }{ {3:│}{1: }{ |
  375. {1: }{9: i}{8:f(n > 1)}{9: }{3:│}{1: }{9: i}{8:nt i;}{9: }|
  376. {1: }{2:------------------}{3:│}{1: }{4: for(i = 0; i }|
  377. {1: } { {3:│}{1: } { |
  378. {1: }{9: }{8:return fac}{3:│}{1: }{9: }{8:printf("%}|
  379. {1: } } {3:│}{1: } } |
  380. {1: }{4: return 1; }{3:│}{1: }{2:-----------------}|
  381. {1: }} {3:│}{1: }} |
  382. {1: } {3:│}{1: } |
  383. {1: }int main(int argc,{3:│}{1: }int main(int argc|
  384. {1: }{ {3:│}{1: }{ |
  385. {1: }{9: frobnitz(f}{8:act}{9:(}{3:│}{1: }{9: frobnitz(f}{8:ib}{9:(}|
  386. {1: }^} {3:│}{1: }} |
  387. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  388. :set diffopt=internal,filler |
  389. ]])
  390. end)
  391. it('diffopt+=algorithm:patience', function()
  392. reread()
  393. feed(':set diffopt=internal,filler,algorithm:patience<cr>')
  394. screen:expect([[
  395. {1: }^#include <stdio.h>{3:│}{1: }#include <stdio.h|
  396. {1: } {3:│}{1: } |
  397. {1: }{2:------------------}{3:│}{1: }{4:int fib(int n) }|
  398. {1: }{2:------------------}{3:│}{1: }{4:{ }|
  399. {1: }{2:------------------}{3:│}{1: }{4: if(n > 2) }|
  400. {1: }{2:------------------}{3:│}{1: }{4: { }|
  401. {1: }{2:------------------}{3:│}{1: }{4: return fi}|
  402. {1: }{2:------------------}{3:│}{1: }{4: } }|
  403. {1: }{2:------------------}{3:│}{1: }{4: return 1; }|
  404. {1: }{2:------------------}{3:│}{1: }{4:} }|
  405. {1: }{2:------------------}{3:│}{1: }{4: }|
  406. {1: }// Frobs foo heart{3:│}{1: }// Frobs foo hear|
  407. {1: }int frobnitz(int f{3:│}{1: }int frobnitz(int |
  408. {1: }{ {3:│}{1: }{ |
  409. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  410. |
  411. ]])
  412. feed('G')
  413. screen:expect([[
  414. {1: } {3:│}{1: } |
  415. {1: }{4:int fact(int n) }{3:│}{1: }{2:-----------------}|
  416. {1: }{4:{ }{3:│}{1: }{2:-----------------}|
  417. {1: }{4: if(n > 1) }{3:│}{1: }{2:-----------------}|
  418. {1: }{4: { }{3:│}{1: }{2:-----------------}|
  419. {1: }{4: return fac}{3:│}{1: }{2:-----------------}|
  420. {1: }{4: } }{3:│}{1: }{2:-----------------}|
  421. {1: }{4: return 1; }{3:│}{1: }{2:-----------------}|
  422. {1: }{4:} }{3:│}{1: }{2:-----------------}|
  423. {1: }{4: }{3:│}{1: }{2:-----------------}|
  424. {1: }int main(int argc,{3:│}{1: }int main(int argc|
  425. {1: }{ {3:│}{1: }{ |
  426. {1: }{9: frobnitz(f}{8:act}{9:(}{3:│}{1: }{9: frobnitz(f}{8:ib}{9:(}|
  427. {1: }^} {3:│}{1: }} |
  428. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  429. |
  430. ]])
  431. end)
  432. it('diffopt+=algorithm:histogram', function()
  433. reread()
  434. feed(':set diffopt=internal,filler,algorithm:histogram<cr>')
  435. screen:expect([[
  436. {1: }^#include <stdio.h>{3:│}{1: }#include <stdio.h|
  437. {1: } {3:│}{1: } |
  438. {1: }{2:------------------}{3:│}{1: }{4:int fib(int n) }|
  439. {1: }{2:------------------}{3:│}{1: }{4:{ }|
  440. {1: }{2:------------------}{3:│}{1: }{4: if(n > 2) }|
  441. {1: }{2:------------------}{3:│}{1: }{4: { }|
  442. {1: }{2:------------------}{3:│}{1: }{4: return fi}|
  443. {1: }{2:------------------}{3:│}{1: }{4: } }|
  444. {1: }{2:------------------}{3:│}{1: }{4: return 1; }|
  445. {1: }{2:------------------}{3:│}{1: }{4:} }|
  446. {1: }{2:------------------}{3:│}{1: }{4: }|
  447. {1: }// Frobs foo heart{3:│}{1: }// Frobs foo hear|
  448. {1: }int frobnitz(int f{3:│}{1: }int frobnitz(int |
  449. {1: }{ {3:│}{1: }{ |
  450. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  451. |
  452. ]])
  453. feed('G')
  454. screen:expect([[
  455. {1: } {3:│}{1: } |
  456. {1: }{4:int fact(int n) }{3:│}{1: }{2:-----------------}|
  457. {1: }{4:{ }{3:│}{1: }{2:-----------------}|
  458. {1: }{4: if(n > 1) }{3:│}{1: }{2:-----------------}|
  459. {1: }{4: { }{3:│}{1: }{2:-----------------}|
  460. {1: }{4: return fac}{3:│}{1: }{2:-----------------}|
  461. {1: }{4: } }{3:│}{1: }{2:-----------------}|
  462. {1: }{4: return 1; }{3:│}{1: }{2:-----------------}|
  463. {1: }{4:} }{3:│}{1: }{2:-----------------}|
  464. {1: }{4: }{3:│}{1: }{2:-----------------}|
  465. {1: }int main(int argc,{3:│}{1: }int main(int argc|
  466. {1: }{ {3:│}{1: }{ |
  467. {1: }{9: frobnitz(f}{8:act}{9:(}{3:│}{1: }{9: frobnitz(f}{8:ib}{9:(}|
  468. {1: }^} {3:│}{1: }} |
  469. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  470. |
  471. ]])
  472. end)
  473. end)
  474. describe('diffopt+=indent-heuristic', function()
  475. setup(function()
  476. local f1 = [[
  477. def finalize(values)
  478. values.each do |v|
  479. v.finalize
  480. end]]
  481. write_file(fname, f1, false)
  482. local f2 = [[
  483. def finalize(values)
  484. values.each do |v|
  485. v.prepare
  486. end
  487. values.each do |v|
  488. v.finalize
  489. end]]
  490. write_file(fname_2, f2, false)
  491. feed(':diffupdate!<cr>')
  492. end)
  493. it('internal', function()
  494. reread()
  495. feed(":set diffopt=internal,filler<cr>")
  496. screen:expect([[
  497. {1: }^def finalize(value{3:│}{1: }def finalize(valu|
  498. {1: } {3:│}{1: } |
  499. {1: } values.each do |{3:│}{1: } values.each do |
  500. {1: }{2:------------------}{3:│}{1: }{4: v.prepare }|
  501. {1: }{2:------------------}{3:│}{1: }{4: end }|
  502. {1: }{2:------------------}{3:│}{1: }{4: }|
  503. {1: }{2:------------------}{3:│}{1: }{4: values.each do }|
  504. {1: } v.finalize {3:│}{1: } v.finalize |
  505. {1: } end {3:│}{1: } end |
  506. {1: }{6:~ }{3:│}{1: }{6:~ }|
  507. {1: }{6:~ }{3:│}{1: }{6:~ }|
  508. {1: }{6:~ }{3:│}{1: }{6:~ }|
  509. {1: }{6:~ }{3:│}{1: }{6:~ }|
  510. {1: }{6:~ }{3:│}{1: }{6:~ }|
  511. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  512. :set diffopt=internal,filler |
  513. ]])
  514. end)
  515. it('indent-heuristic', function()
  516. reread()
  517. feed(':set diffopt=internal,filler,indent-heuristic<cr>')
  518. screen:expect([[
  519. {1: }^def finalize(value{3:│}{1: }def finalize(valu|
  520. {1: } {3:│}{1: } |
  521. {1: }{2:------------------}{3:│}{1: }{4: values.each do }|
  522. {1: }{2:------------------}{3:│}{1: }{4: v.prepare }|
  523. {1: }{2:------------------}{3:│}{1: }{4: end }|
  524. {1: }{2:------------------}{3:│}{1: }{4: }|
  525. {1: } values.each do |{3:│}{1: } values.each do |
  526. {1: } v.finalize {3:│}{1: } v.finalize |
  527. {1: } end {3:│}{1: } end |
  528. {1: }{6:~ }{3:│}{1: }{6:~ }|
  529. {1: }{6:~ }{3:│}{1: }{6:~ }|
  530. {1: }{6:~ }{3:│}{1: }{6:~ }|
  531. {1: }{6:~ }{3:│}{1: }{6:~ }|
  532. {1: }{6:~ }{3:│}{1: }{6:~ }|
  533. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  534. |
  535. ]])
  536. end)
  537. it('indent-heuristic random order', function()
  538. reread()
  539. feed(':set diffopt=internal,filler,indent-heuristic,algorithm:patience<cr>')
  540. feed(':<cr>')
  541. screen:expect([[
  542. {1: }^def finalize(value{3:│}{1: }def finalize(valu|
  543. {1: } {3:│}{1: } |
  544. {1: }{2:------------------}{3:│}{1: }{4: values.each do }|
  545. {1: }{2:------------------}{3:│}{1: }{4: v.prepare }|
  546. {1: }{2:------------------}{3:│}{1: }{4: end }|
  547. {1: }{2:------------------}{3:│}{1: }{4: }|
  548. {1: } values.each do |{3:│}{1: } values.each do |
  549. {1: } v.finalize {3:│}{1: } v.finalize |
  550. {1: } end {3:│}{1: } end |
  551. {1: }{6:~ }{3:│}{1: }{6:~ }|
  552. {1: }{6:~ }{3:│}{1: }{6:~ }|
  553. {1: }{6:~ }{3:│}{1: }{6:~ }|
  554. {1: }{6:~ }{3:│}{1: }{6:~ }|
  555. {1: }{6:~ }{3:│}{1: }{6:~ }|
  556. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  557. : |
  558. ]])
  559. end)
  560. end)
  561. it('Diff the same file', function()
  562. write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  563. write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false)
  564. reread()
  565. feed(':set diffopt=filler<cr>')
  566. screen:expect([[
  567. {1:+ }{5:^+-- 10 lines: 1···}{3:│}{1:+ }{5:+-- 10 lines: 1··}|
  568. {1: }{6:~ }{3:│}{1: }{6:~ }|
  569. {1: }{6:~ }{3:│}{1: }{6:~ }|
  570. {1: }{6:~ }{3:│}{1: }{6:~ }|
  571. {1: }{6:~ }{3:│}{1: }{6:~ }|
  572. {1: }{6:~ }{3:│}{1: }{6:~ }|
  573. {1: }{6:~ }{3:│}{1: }{6:~ }|
  574. {1: }{6:~ }{3:│}{1: }{6:~ }|
  575. {1: }{6:~ }{3:│}{1: }{6:~ }|
  576. {1: }{6:~ }{3:│}{1: }{6:~ }|
  577. {1: }{6:~ }{3:│}{1: }{6:~ }|
  578. {1: }{6:~ }{3:│}{1: }{6:~ }|
  579. {1: }{6:~ }{3:│}{1: }{6:~ }|
  580. {1: }{6:~ }{3:│}{1: }{6:~ }|
  581. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  582. :set diffopt=filler |
  583. ]])
  584. feed(':set diffopt+=internal<cr>')
  585. screen:expect([[
  586. {1:+ }{5:^+-- 10 lines: 1···}{3:│}{1:+ }{5:+-- 10 lines: 1··}|
  587. {1: }{6:~ }{3:│}{1: }{6:~ }|
  588. {1: }{6:~ }{3:│}{1: }{6:~ }|
  589. {1: }{6:~ }{3:│}{1: }{6:~ }|
  590. {1: }{6:~ }{3:│}{1: }{6:~ }|
  591. {1: }{6:~ }{3:│}{1: }{6:~ }|
  592. {1: }{6:~ }{3:│}{1: }{6:~ }|
  593. {1: }{6:~ }{3:│}{1: }{6:~ }|
  594. {1: }{6:~ }{3:│}{1: }{6:~ }|
  595. {1: }{6:~ }{3:│}{1: }{6:~ }|
  596. {1: }{6:~ }{3:│}{1: }{6:~ }|
  597. {1: }{6:~ }{3:│}{1: }{6:~ }|
  598. {1: }{6:~ }{3:│}{1: }{6:~ }|
  599. {1: }{6:~ }{3:│}{1: }{6:~ }|
  600. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  601. :set diffopt+=internal |
  602. ]])
  603. end)
  604. it('Diff an empty file', function()
  605. write_file(fname, "", false)
  606. write_file(fname_2, "", false)
  607. reread()
  608. feed(':set diffopt=filler<cr>')
  609. screen:expect([[
  610. {1:- }^ {3:│}{1:- } |
  611. {1: }{6:~ }{3:│}{1: }{6:~ }|
  612. {1: }{6:~ }{3:│}{1: }{6:~ }|
  613. {1: }{6:~ }{3:│}{1: }{6:~ }|
  614. {1: }{6:~ }{3:│}{1: }{6:~ }|
  615. {1: }{6:~ }{3:│}{1: }{6:~ }|
  616. {1: }{6:~ }{3:│}{1: }{6:~ }|
  617. {1: }{6:~ }{3:│}{1: }{6:~ }|
  618. {1: }{6:~ }{3:│}{1: }{6:~ }|
  619. {1: }{6:~ }{3:│}{1: }{6:~ }|
  620. {1: }{6:~ }{3:│}{1: }{6:~ }|
  621. {1: }{6:~ }{3:│}{1: }{6:~ }|
  622. {1: }{6:~ }{3:│}{1: }{6:~ }|
  623. {1: }{6:~ }{3:│}{1: }{6:~ }|
  624. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  625. :set diffopt=filler |
  626. ]])
  627. feed(':set diffopt+=internal<cr>')
  628. screen:expect([[
  629. {1:- }^ {3:│}{1:- } |
  630. {1: }{6:~ }{3:│}{1: }{6:~ }|
  631. {1: }{6:~ }{3:│}{1: }{6:~ }|
  632. {1: }{6:~ }{3:│}{1: }{6:~ }|
  633. {1: }{6:~ }{3:│}{1: }{6:~ }|
  634. {1: }{6:~ }{3:│}{1: }{6:~ }|
  635. {1: }{6:~ }{3:│}{1: }{6:~ }|
  636. {1: }{6:~ }{3:│}{1: }{6:~ }|
  637. {1: }{6:~ }{3:│}{1: }{6:~ }|
  638. {1: }{6:~ }{3:│}{1: }{6:~ }|
  639. {1: }{6:~ }{3:│}{1: }{6:~ }|
  640. {1: }{6:~ }{3:│}{1: }{6:~ }|
  641. {1: }{6:~ }{3:│}{1: }{6:~ }|
  642. {1: }{6:~ }{3:│}{1: }{6:~ }|
  643. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  644. :set diffopt+=internal |
  645. ]])
  646. end)
  647. it('diffopt+=icase', function()
  648. write_file(fname, "a\nb\ncd\n", false)
  649. write_file(fname_2, "A\nb\ncDe\n", false)
  650. reread()
  651. feed(':set diffopt=filler,icase<cr>')
  652. screen:expect([[
  653. {1: }^a {3:│}{1: }A |
  654. {1: }b {3:│}{1: }b |
  655. {1: }{9:cd }{3:│}{1: }{9:cD}{8:e}{9: }|
  656. {1: }{6:~ }{3:│}{1: }{6:~ }|
  657. {1: }{6:~ }{3:│}{1: }{6:~ }|
  658. {1: }{6:~ }{3:│}{1: }{6:~ }|
  659. {1: }{6:~ }{3:│}{1: }{6:~ }|
  660. {1: }{6:~ }{3:│}{1: }{6:~ }|
  661. {1: }{6:~ }{3:│}{1: }{6:~ }|
  662. {1: }{6:~ }{3:│}{1: }{6:~ }|
  663. {1: }{6:~ }{3:│}{1: }{6:~ }|
  664. {1: }{6:~ }{3:│}{1: }{6:~ }|
  665. {1: }{6:~ }{3:│}{1: }{6:~ }|
  666. {1: }{6:~ }{3:│}{1: }{6:~ }|
  667. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  668. :set diffopt=filler,icase |
  669. ]])
  670. feed(':set diffopt+=internal<cr>')
  671. screen:expect([[
  672. {1: }^a {3:│}{1: }A |
  673. {1: }b {3:│}{1: }b |
  674. {1: }{9:cd }{3:│}{1: }{9:cD}{8:e}{9: }|
  675. {1: }{6:~ }{3:│}{1: }{6:~ }|
  676. {1: }{6:~ }{3:│}{1: }{6:~ }|
  677. {1: }{6:~ }{3:│}{1: }{6:~ }|
  678. {1: }{6:~ }{3:│}{1: }{6:~ }|
  679. {1: }{6:~ }{3:│}{1: }{6:~ }|
  680. {1: }{6:~ }{3:│}{1: }{6:~ }|
  681. {1: }{6:~ }{3:│}{1: }{6:~ }|
  682. {1: }{6:~ }{3:│}{1: }{6:~ }|
  683. {1: }{6:~ }{3:│}{1: }{6:~ }|
  684. {1: }{6:~ }{3:│}{1: }{6:~ }|
  685. {1: }{6:~ }{3:│}{1: }{6:~ }|
  686. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  687. :set diffopt+=internal |
  688. ]])
  689. end)
  690. describe('diffopt+=iwhite', function()
  691. setup(function()
  692. local f1 = 'int main()\n{\n printf("Hello, World!");\n return 0;\n}\n'
  693. write_file(fname, f1, false)
  694. local f2 = 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n'
  695. write_file(fname_2, f2, false)
  696. feed(':diffupdate!<cr>')
  697. end)
  698. it('external', function()
  699. reread()
  700. feed(':set diffopt=filler,iwhite<cr>')
  701. screen:expect([[
  702. {1: }^int main() {3:│}{1: }int main() |
  703. {1: }{ {3:│}{1: }{ |
  704. {1: }{2:------------------}{3:│}{1: }{4: if (0) }|
  705. {1: }{2:------------------}{3:│}{1: }{4: { }|
  706. {1: } printf("Hello, {3:│}{1: } printf("Hel|
  707. {1: } return 0; {3:│}{1: } return 0; |
  708. {1: }{2:------------------}{3:│}{1: }{4: } }|
  709. {1: }} {3:│}{1: }} |
  710. {1: }{6:~ }{3:│}{1: }{6:~ }|
  711. {1: }{6:~ }{3:│}{1: }{6:~ }|
  712. {1: }{6:~ }{3:│}{1: }{6:~ }|
  713. {1: }{6:~ }{3:│}{1: }{6:~ }|
  714. {1: }{6:~ }{3:│}{1: }{6:~ }|
  715. {1: }{6:~ }{3:│}{1: }{6:~ }|
  716. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  717. :set diffopt=filler,iwhite |
  718. ]])
  719. end)
  720. it('internal', function()
  721. reread()
  722. feed(':set diffopt=filler,iwhite,internal<cr>')
  723. screen:expect([[
  724. {1: }^int main() {3:│}{1: }int main() |
  725. {1: }{ {3:│}{1: }{ |
  726. {1: }{2:------------------}{3:│}{1: }{4: if (0) }|
  727. {1: }{2:------------------}{3:│}{1: }{4: { }|
  728. {1: } printf("Hello, {3:│}{1: } printf("Hel|
  729. {1: } return 0; {3:│}{1: } return 0; |
  730. {1: }{2:------------------}{3:│}{1: }{4: } }|
  731. {1: }} {3:│}{1: }} |
  732. {1: }{6:~ }{3:│}{1: }{6:~ }|
  733. {1: }{6:~ }{3:│}{1: }{6:~ }|
  734. {1: }{6:~ }{3:│}{1: }{6:~ }|
  735. {1: }{6:~ }{3:│}{1: }{6:~ }|
  736. {1: }{6:~ }{3:│}{1: }{6:~ }|
  737. {1: }{6:~ }{3:│}{1: }{6:~ }|
  738. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  739. :set diffopt=filler,iwhite,internal |
  740. ]])
  741. end)
  742. end)
  743. describe('diffopt+=iblank', function()
  744. setup(function()
  745. write_file(fname, 'a\n\n \ncd\nef\nxxx\n', false)
  746. write_file(fname_2, 'a\ncd\n\nef\nyyy\n', false)
  747. feed(':diffupdate!<cr>')
  748. end)
  749. it('generic', function()
  750. reread()
  751. feed(':set diffopt=internal,filler,iblank<cr>')
  752. screen:expect([[
  753. {1: }^a {3:│}{1: }a |
  754. {1: }{4: }{3:│}{1: }{2:-----------------}|
  755. {1: }{4: }{3:│}{1: }{2:-----------------}|
  756. {1: }cd {3:│}{1: }cd |
  757. {1: }ef {3:│}{1: } |
  758. {1: }{8:xxx}{9: }{3:│}{1: }ef |
  759. {1: }{6:~ }{3:│}{1: }{8:yyy}{9: }|
  760. {1: }{6:~ }{3:│}{1: }{6:~ }|
  761. {1: }{6:~ }{3:│}{1: }{6:~ }|
  762. {1: }{6:~ }{3:│}{1: }{6:~ }|
  763. {1: }{6:~ }{3:│}{1: }{6:~ }|
  764. {1: }{6:~ }{3:│}{1: }{6:~ }|
  765. {1: }{6:~ }{3:│}{1: }{6:~ }|
  766. {1: }{6:~ }{3:│}{1: }{6:~ }|
  767. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  768. :set diffopt=internal,filler,iblank |
  769. ]])
  770. end)
  771. it('diffopt+=iwhite', function()
  772. reread()
  773. feed(':set diffopt=internal,filler,iblank,iwhite<cr>')
  774. feed(':<cr>')
  775. screen:expect([[
  776. {1: }^a {3:│}{1: }a |
  777. {1: } {3:│}{1: }cd |
  778. {1: } {3:│}{1: } |
  779. {1: }cd {3:│}{1: }ef |
  780. {1: }ef {3:│}{1: }{8:yyy}{9: }|
  781. {1: }{8:xxx}{9: }{3:│}{1: }{6:~ }|
  782. {1: }{6:~ }{3:│}{1: }{6:~ }|
  783. {1: }{6:~ }{3:│}{1: }{6:~ }|
  784. {1: }{6:~ }{3:│}{1: }{6:~ }|
  785. {1: }{6:~ }{3:│}{1: }{6:~ }|
  786. {1: }{6:~ }{3:│}{1: }{6:~ }|
  787. {1: }{6:~ }{3:│}{1: }{6:~ }|
  788. {1: }{6:~ }{3:│}{1: }{6:~ }|
  789. {1: }{6:~ }{3:│}{1: }{6:~ }|
  790. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  791. : |
  792. ]])
  793. end)
  794. it('diffopt+=iwhiteall', function()
  795. reread()
  796. feed(':set diffopt=internal,filler,iblank,iwhiteall<cr>')
  797. feed(':<cr>')
  798. screen:expect([[
  799. {1: }^a {3:│}{1: }a |
  800. {1: } {3:│}{1: }cd |
  801. {1: } {3:│}{1: } |
  802. {1: }cd {3:│}{1: }ef |
  803. {1: }ef {3:│}{1: }{8:yyy}{9: }|
  804. {1: }{8:xxx}{9: }{3:│}{1: }{6:~ }|
  805. {1: }{6:~ }{3:│}{1: }{6:~ }|
  806. {1: }{6:~ }{3:│}{1: }{6:~ }|
  807. {1: }{6:~ }{3:│}{1: }{6:~ }|
  808. {1: }{6:~ }{3:│}{1: }{6:~ }|
  809. {1: }{6:~ }{3:│}{1: }{6:~ }|
  810. {1: }{6:~ }{3:│}{1: }{6:~ }|
  811. {1: }{6:~ }{3:│}{1: }{6:~ }|
  812. {1: }{6:~ }{3:│}{1: }{6:~ }|
  813. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  814. : |
  815. ]])
  816. end)
  817. it('diffopt+=iwhiteeol', function()
  818. reread()
  819. feed(':set diffopt=internal,filler,iblank,iwhiteeol<cr>')
  820. feed(':<cr>')
  821. screen:expect([[
  822. {1: }^a {3:│}{1: }a |
  823. {1: } {3:│}{1: }cd |
  824. {1: } {3:│}{1: } |
  825. {1: }cd {3:│}{1: }ef |
  826. {1: }ef {3:│}{1: }{8:yyy}{9: }|
  827. {1: }{8:xxx}{9: }{3:│}{1: }{6:~ }|
  828. {1: }{6:~ }{3:│}{1: }{6:~ }|
  829. {1: }{6:~ }{3:│}{1: }{6:~ }|
  830. {1: }{6:~ }{3:│}{1: }{6:~ }|
  831. {1: }{6:~ }{3:│}{1: }{6:~ }|
  832. {1: }{6:~ }{3:│}{1: }{6:~ }|
  833. {1: }{6:~ }{3:│}{1: }{6:~ }|
  834. {1: }{6:~ }{3:│}{1: }{6:~ }|
  835. {1: }{6:~ }{3:│}{1: }{6:~ }|
  836. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  837. : |
  838. ]])
  839. end)
  840. end)
  841. describe('diffopt+=iwhite{eol,all}', function()
  842. setup(function()
  843. write_file(fname, 'a \nx\ncd\nef\nxx xx\nfoo\nbar\n', false)
  844. write_file(fname_2, 'a\nx\nc d\n ef\nxx xx\nfoo\n\nbar\n', false)
  845. feed(':diffupdate!<cr>')
  846. end)
  847. it('diffopt+=iwhiteeol', function()
  848. reread()
  849. feed(':set diffopt=internal,filler,iwhiteeol<cr>')
  850. feed(':<cr>')
  851. screen:expect([[
  852. {1: }^a {3:│}{1: }a |
  853. {1: }x {3:│}{1: }x |
  854. {1: }{9:cd }{3:│}{1: }{9:c}{8: }{9:d }|
  855. {1: }{9:ef }{3:│}{1: }{8: }{9:ef }|
  856. {1: }{9:xx }{8: }{9:xx }{3:│}{1: }{9:xx xx }|
  857. {1: }foo {3:│}{1: }foo |
  858. {1: }{2:------------------}{3:│}{1: }{4: }|
  859. {1: }bar {3:│}{1: }bar |
  860. {1: }{6:~ }{3:│}{1: }{6:~ }|
  861. {1: }{6:~ }{3:│}{1: }{6:~ }|
  862. {1: }{6:~ }{3:│}{1: }{6:~ }|
  863. {1: }{6:~ }{3:│}{1: }{6:~ }|
  864. {1: }{6:~ }{3:│}{1: }{6:~ }|
  865. {1: }{6:~ }{3:│}{1: }{6:~ }|
  866. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  867. : |
  868. ]])
  869. end)
  870. it('diffopt+=iwhiteall', function()
  871. reread()
  872. feed(':set diffopt=internal,filler,iwhiteall<cr>')
  873. feed(':<cr>')
  874. screen:expect([[
  875. {1: }^a {3:│}{1: }a |
  876. {1: }x {3:│}{1: }x |
  877. {1: }cd {3:│}{1: }c d |
  878. {1: }ef {3:│}{1: } ef |
  879. {1: }xx xx {3:│}{1: }xx xx |
  880. {1: }foo {3:│}{1: }foo |
  881. {1: }{2:------------------}{3:│}{1: }{4: }|
  882. {1: }bar {3:│}{1: }bar |
  883. {1: }{6:~ }{3:│}{1: }{6:~ }|
  884. {1: }{6:~ }{3:│}{1: }{6:~ }|
  885. {1: }{6:~ }{3:│}{1: }{6:~ }|
  886. {1: }{6:~ }{3:│}{1: }{6:~ }|
  887. {1: }{6:~ }{3:│}{1: }{6:~ }|
  888. {1: }{6:~ }{3:│}{1: }{6:~ }|
  889. {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }|
  890. : |
  891. ]])
  892. end)
  893. end)
  894. end)