scroll_opt_spec.lua 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  1. local n = require('test.functional.testnvim')()
  2. local Screen = require('test.functional.ui.screen')
  3. local clear = n.clear
  4. local exec = n.exec
  5. local feed = n.feed
  6. local assert_alive = n.assert_alive
  7. before_each(clear)
  8. describe('smoothscroll', function()
  9. local screen
  10. before_each(function()
  11. screen = Screen.new(40, 12)
  12. end)
  13. -- oldtest: Test_CtrlE_CtrlY_stop_at_end()
  14. it('disabled does not break <C-E> and <C-Y> stop at end', function()
  15. exec([[
  16. enew
  17. call setline(1, ['one', 'two'])
  18. set number
  19. ]])
  20. feed('<C-Y>')
  21. screen:expect({ any = '{8: 1 }^one' })
  22. feed('<C-E><C-E><C-E>')
  23. screen:expect({ any = '{8: 2 }^two' })
  24. end)
  25. -- oldtest: Test_smoothscroll_CtrlE_CtrlY()
  26. it('works with <C-E> and <C-E>', function()
  27. exec([[
  28. call setline(1, [ 'line one', 'word '->repeat(20), 'line three', 'long word '->repeat(7), 'line', 'line', 'line', ])
  29. set smoothscroll scrolloff=5
  30. :5
  31. ]])
  32. local s1 = [[
  33. word word word word word word word word |*2
  34. word word word word |
  35. line three |
  36. long word long word long word long word |
  37. long word long word long word |
  38. ^line |
  39. line |*2
  40. {1:~ }|*2
  41. |
  42. ]]
  43. local s2 = [[
  44. {1:<<<}d word word word word word word word |
  45. word word word word |
  46. line three |
  47. long word long word long word long word |
  48. long word long word long word |
  49. ^line |
  50. line |*2
  51. {1:~ }|*3
  52. |
  53. ]]
  54. local s3 = [[
  55. {1:<<<}d word word word |
  56. line three |
  57. long word long word long word long word |
  58. long word long word long word |
  59. ^line |
  60. line |*2
  61. {1:~ }|*4
  62. |
  63. ]]
  64. local s4 = [[
  65. line three |
  66. long word long word long word long word |
  67. long word long word long word |
  68. line |*2
  69. ^line |
  70. {1:~ }|*5
  71. |
  72. ]]
  73. local s5 = [[
  74. {1:<<<}d word word word |
  75. line three |
  76. long word long word long word long word |
  77. long word long word long word |
  78. line |*2
  79. ^line |
  80. {1:~ }|*4
  81. |
  82. ]]
  83. local s6 = [[
  84. {1:<<<}d word word word word word word word |
  85. word word word word |
  86. line three |
  87. long word long word long word long word |
  88. long word long word long word |
  89. line |*2
  90. ^line |
  91. {1:~ }|*3
  92. |
  93. ]]
  94. local s7 = [[
  95. word word word word word word word word |*2
  96. word word word word |
  97. line three |
  98. long word long word long word long word |
  99. long word long word long word |
  100. line |*2
  101. ^line |
  102. {1:~ }|*2
  103. |
  104. ]]
  105. local s8 = [[
  106. line one |
  107. word word word word word word word word |*2
  108. word word word word |
  109. line three |
  110. long word long word long word long word |
  111. long word long word long word |
  112. line |*2
  113. ^line |
  114. {1:~ }|
  115. |
  116. ]]
  117. feed('<C-E>')
  118. screen:expect(s1)
  119. feed('<C-E>')
  120. screen:expect(s2)
  121. feed('<C-E>')
  122. screen:expect(s3)
  123. feed('<C-E>')
  124. screen:expect(s4)
  125. feed('<C-Y>')
  126. screen:expect(s5)
  127. feed('<C-Y>')
  128. screen:expect(s6)
  129. feed('<C-Y>')
  130. screen:expect(s7)
  131. feed('<C-Y>')
  132. screen:expect(s8)
  133. exec('set foldmethod=indent')
  134. -- move the cursor so we can reuse the same dumps
  135. feed('5G<C-E>')
  136. screen:expect(s1)
  137. feed('<C-E>')
  138. screen:expect(s2)
  139. feed('7G<C-Y>')
  140. screen:expect(s7)
  141. feed('<C-Y>')
  142. screen:expect(s8)
  143. end)
  144. -- oldtest: Test_smoothscroll_multibyte()
  145. it('works with multibyte characters', function()
  146. screen:try_resize(40, 6)
  147. exec([[
  148. set scrolloff=0 smoothscroll
  149. call setline(1, [repeat('ϛ', 45), repeat('2', 36)])
  150. exe "normal G35l\<C-E>k"
  151. ]])
  152. screen:expect([[
  153. ϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛϛ^ϛϛϛϛϛ|
  154. ϛϛϛϛϛ |
  155. 222222222222222222222222222222222222 |
  156. {1:~ }|*2
  157. |
  158. ]])
  159. end)
  160. -- oldtest: Test_smoothscroll_number()
  161. it("works 'number' and 'cpo'+=n", function()
  162. exec([[
  163. call setline(1, [ 'one ' .. 'word '->repeat(20), 'two ' .. 'long word '->repeat(7), 'line', 'line', 'line', ])
  164. set smoothscroll scrolloff=5
  165. set splitkeep=topline
  166. set number cpo+=n
  167. :3
  168. func g:DoRel()
  169. set number relativenumber scrolloff=0
  170. :%del
  171. call setline(1, [ 'one', 'very long text '->repeat(12), 'three', ])
  172. exe "normal 2Gzt\<C-E>"
  173. endfunc
  174. ]])
  175. screen:expect([[
  176. {8: 1 }one word word word word word word wo|
  177. rd word word word word word word word wo|
  178. rd word word word word word |
  179. {8: 2 }two long word long word long word lo|
  180. ng word long word long word long word |
  181. {8: 3 }^line |
  182. {8: 4 }line |
  183. {8: 5 }line |
  184. {1:~ }|*3
  185. |
  186. ]])
  187. feed('<C-E>')
  188. screen:expect([[
  189. {1:<<<}word word word word word word word wo|
  190. rd word word word word word |
  191. {8: 2 }two long word long word long word lo|
  192. ng word long word long word long word |
  193. {8: 3 }^line |
  194. {8: 4 }line |
  195. {8: 5 }line |
  196. {1:~ }|*4
  197. |
  198. ]])
  199. feed('<C-E>')
  200. screen:expect([[
  201. {1:<<<}word word word word word |
  202. {8: 2 }two long word long word long word lo|
  203. ng word long word long word long word |
  204. {8: 3 }^line |
  205. {8: 4 }line |
  206. {8: 5 }line |
  207. {1:~ }|*5
  208. |
  209. ]])
  210. exec('set cpo-=n')
  211. screen:expect([[
  212. {1:<<<}{8: }d word word word word word word |
  213. {8: 2 }two long word long word long word lo|
  214. {8: }ng word long word long word long wor|
  215. {8: }d |
  216. {8: 3 }^line |
  217. {8: 4 }line |
  218. {8: 5 }line |
  219. {1:~ }|*4
  220. |
  221. ]])
  222. feed('<C-Y>')
  223. screen:expect([[
  224. {1:<<<}{8: }rd word word word word word word wor|
  225. {8: }d word word word word word word |
  226. {8: 2 }two long word long word long word lo|
  227. {8: }ng word long word long word long wor|
  228. {8: }d |
  229. {8: 3 }^line |
  230. {8: 4 }line |
  231. {8: 5 }line |
  232. {1:~ }|*3
  233. |
  234. ]])
  235. feed('<C-Y>')
  236. screen:expect([[
  237. {8: 1 }one word word word word word word wo|
  238. {8: }rd word word word word word word wor|
  239. {8: }d word word word word word word |
  240. {8: 2 }two long word long word long word lo|
  241. {8: }ng word long word long word long wor|
  242. {8: }d |
  243. {8: 3 }^line |
  244. {8: 4 }line |
  245. {8: 5 }line |
  246. {1:~ }|*2
  247. |
  248. ]])
  249. exec('botright split')
  250. feed('gg')
  251. screen:expect([[
  252. {8: 1 }one word word word word word word wo|
  253. {8: }rd word word word word word word wor|
  254. {8: }d word word word word word word |
  255. {8: 2 }two long word long word long word{1:@@@}|
  256. {2:[No Name] [+] }|
  257. {8: 1 }^one word word word word word word wo|
  258. {8: }rd word word word word word word wor|
  259. {8: }d word word word word word word |
  260. {8: 2 }two long word long word long word lo|
  261. {8: }ng word long word long word long {1:@@@}|
  262. {3:[No Name] [+] }|
  263. |
  264. ]])
  265. feed('<C-E>')
  266. screen:expect([[
  267. {8: 1 }one word word word word word word wo|
  268. {8: }rd word word word word word word wor|
  269. {8: }d word word word word word word |
  270. {8: 2 }two long word long word long word{1:@@@}|
  271. {2:[No Name] [+] }|
  272. {1:<<<}{8: }rd word word word word word word wor|
  273. {8: }d word word word word word word^ |
  274. {8: 2 }two long word long word long word lo|
  275. {8: }ng word long word long word long wor|
  276. {8: }d |
  277. {3:[No Name] [+] }|
  278. |
  279. ]])
  280. feed('<C-E>')
  281. screen:expect([[
  282. {8: 1 }one word word word word word word wo|
  283. {8: }rd word word word word word word wor|
  284. {8: }d word word word word word word |
  285. {8: 2 }two long word long word long word{1:@@@}|
  286. {2:[No Name] [+] }|
  287. {1:<<<}{8: }d word word word word word word^ |
  288. {8: 2 }two long word long word long word lo|
  289. {8: }ng word long word long word long wor|
  290. {8: }d |
  291. {8: 3 }line |
  292. {3:[No Name] [+] }|
  293. |
  294. ]])
  295. exec('close')
  296. exec('call DoRel()')
  297. screen:expect([[
  298. {8:2}{1:<<<}^ong text very long text very long te|
  299. {8: }xt very long text very long text ver|
  300. {8: }y long text very long text very long|
  301. {8: } text very long text very long text |
  302. {8: 1 }three |
  303. {1:~ }|*6
  304. --No lines in buffer-- |
  305. ]])
  306. end)
  307. -- oldtest: Test_smoothscroll_list()
  308. it('works with list mode', function()
  309. screen:try_resize(40, 8)
  310. exec([[
  311. set smoothscroll scrolloff=0
  312. set list
  313. call setline(1, [ 'one', 'very long text '->repeat(12), 'three', ])
  314. exe "normal 2Gzt\<C-E>"
  315. ]])
  316. screen:expect([[
  317. {1:<<<}t very long text very long text very |
  318. ^long text very long text very long text |
  319. very long text very long text very long |
  320. text very long text{1:-} |
  321. three |
  322. {1:~ }|*2
  323. |
  324. ]])
  325. exec('set listchars+=precedes:#')
  326. screen:expect([[
  327. {1:#}ext very long text very long text very |
  328. ^long text very long text very long text |
  329. very long text very long text very long |
  330. text very long text{1:-} |
  331. three |
  332. {1:~ }|*2
  333. |
  334. ]])
  335. end)
  336. -- oldtest: Test_smoothscroll_diff_mode()
  337. it('works with diff mode', function()
  338. screen:try_resize(40, 8)
  339. exec([[
  340. let text = 'just some text here'
  341. call setline(1, text)
  342. set smoothscroll
  343. diffthis
  344. new
  345. call setline(1, text)
  346. set smoothscroll
  347. diffthis
  348. ]])
  349. screen:expect([[
  350. {7:- }^just some text here |
  351. {1:~ }|*2
  352. {3:[No Name] [+] }|
  353. {7:- }just some text here |
  354. {1:~ }|
  355. {2:[No Name] [+] }|
  356. |
  357. ]])
  358. feed('<C-Y>')
  359. screen:expect_unchanged()
  360. feed('<C-E>')
  361. screen:expect_unchanged()
  362. end)
  363. -- oldtest: Test_smoothscroll_diff_change_line()
  364. it('works in diff mode when changing line', function()
  365. screen:try_resize(55, 20)
  366. exec([[
  367. set diffopt+=followwrap smoothscroll
  368. call setline(1, repeat(' abc', &columns))
  369. call setline(2, 'bar')
  370. call setline(3, repeat(' abc', &columns))
  371. vnew
  372. call setline(1, repeat(' abc', &columns))
  373. call setline(2, 'foo')
  374. call setline(3, 'bar')
  375. call setline(4, repeat(' abc', &columns))
  376. windo exe "normal! 2gg5\<C-E>"
  377. windo diffthis
  378. ]])
  379. screen:expect([[
  380. {1:<<<}bc abc abc abc abc abc a│{1:<<<}bc abc abc abc abc abc a|
  381. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  382. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  383. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  384. {7: }{22:foo }│{7: }{23:-------------------------}|
  385. {7: }bar │{7: }^bar |
  386. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  387. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  388. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  389. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  390. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  391. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  392. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  393. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  394. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  395. {1:~ }│{1:~ }|*3
  396. {2:[No Name] [+] }{3:[No Name] [+] }|
  397. |
  398. ]])
  399. feed('Abar')
  400. screen:expect([[
  401. {1:<<<}bc abc abc abc abc abc a│{1:<<<}bc abc abc abc abc abc a|
  402. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  403. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  404. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  405. {7: }{22:foo }│{7: }{23:-------------------------}|
  406. {7: }bar │{7: }barbar^ |
  407. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  408. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  409. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  410. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  411. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  412. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  413. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  414. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  415. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  416. {1:~ }│{1:~ }|*3
  417. {2:[No Name] [+] }{3:[No Name] [+] }|
  418. {5:-- INSERT --} |
  419. ]])
  420. feed('<Esc>')
  421. screen:expect([[
  422. {1:<<<}bc abc abc abc abc abc a│{1:<<<}bc abc abc abc abc abc a|
  423. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  424. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  425. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  426. {7: }{22:foo }│{7: }{23:-------------------------}|
  427. {7: }{4:bar }│{7: }{4:bar}{27:ba^r}{4: }|
  428. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  429. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  430. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  431. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  432. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  433. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  434. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  435. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  436. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  437. {1:~ }│{1:~ }|*3
  438. {2:[No Name] [+] }{3:[No Name] [+] }|
  439. |
  440. ]])
  441. feed('yyp')
  442. screen:expect([[
  443. {1:<<<}bc abc abc abc abc abc a│{1:<<<}bc abc abc abc abc abc a|
  444. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  445. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  446. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  447. {7: }{27:foo}{4: }│{7: }{27:barbar}{4: }|
  448. {7: }{4:bar }│{7: }{4:^bar}{27:bar}{4: }|
  449. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  450. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  451. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  452. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  453. {7: } abc abc abc abc abc abc │{7: } abc abc abc abc abc abc |
  454. {7: }abc abc abc abc abc abc a│{7: }abc abc abc abc abc abc a|
  455. {7: }bc abc abc abc abc abc ab│{7: }bc abc abc abc abc abc ab|
  456. {7: }c abc abc abc abc abc abc│{7: }c abc abc abc abc abc abc|
  457. {7: } abc abc abc abc abc │{7: } abc abc abc abc abc |
  458. {1:~ }│{1:~ }|*3
  459. {2:[No Name] [+] }{3:[No Name] [+] }|
  460. |
  461. ]])
  462. end)
  463. -- oldtest: Test_smoothscroll_wrap_scrolloff_zero()
  464. it("works with zero 'scrolloff'", function()
  465. screen:try_resize(40, 8)
  466. exec([[
  467. call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
  468. set smoothscroll scrolloff=0 display=
  469. :3
  470. ]])
  471. screen:expect([[
  472. {1:<<<}h some text with some text |
  473. Line with some text with some text with |
  474. some text with some text with some text |
  475. with some text with some text |
  476. ^Line with some text with some text with |
  477. some text with some text with some text |
  478. with some text with some text |
  479. |
  480. ]])
  481. feed('j')
  482. screen:expect_unchanged()
  483. -- moving cursor down - whole bottom line shows
  484. feed('<C-E>j')
  485. screen:expect_unchanged()
  486. feed('G')
  487. screen:expect_unchanged()
  488. feed('4<C-Y>G')
  489. screen:expect_unchanged()
  490. -- moving cursor up right after the <<< marker - no need to show whole line
  491. feed('2gj3l2k')
  492. screen:expect([[
  493. {1:<<<}^h some text with some text |
  494. Line with some text with some text with |
  495. some text with some text with some text |
  496. with some text with some text |
  497. Line with some text with some text with |
  498. some text with some text with some text |
  499. with some text with some text |
  500. |
  501. ]])
  502. -- moving cursor up where the <<< marker is - whole top line shows
  503. feed('2j02k')
  504. screen:expect([[
  505. ^Line with some text with some text with |
  506. some text with some text with some text |
  507. with some text with some text |
  508. Line with some text with some text with |
  509. some text with some text with some text |
  510. with some text with some text |
  511. {1:@ }|
  512. |
  513. ]])
  514. end)
  515. -- oldtest: Test_smoothscroll_wrap_long_line()
  516. it('adjusts the cursor position in a long line', function()
  517. screen:try_resize(40, 6)
  518. exec([[
  519. call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(30)) .. ' end', 'four'])
  520. set smoothscroll scrolloff=0
  521. normal 3G10|zt
  522. ]])
  523. -- scrolling up, cursor moves screen line down
  524. screen:expect([[
  525. Line with^ lots of text with lots of text|
  526. with lots of text with lots of text wit|
  527. h lots of text with lots of text with lo|
  528. ts of text with lots of text with lots o|
  529. f text with lots of text with lots of te|
  530. |
  531. ]])
  532. feed('<C-E>')
  533. screen:expect([[
  534. {1:<<<}th lot^s of text with lots of text wit|
  535. h lots of text with lots of text with lo|
  536. ts of text with lots of text with lots o|
  537. f text with lots of text with lots of te|
  538. xt with lots of text with lots of text w|
  539. |
  540. ]])
  541. feed('5<C-E>')
  542. screen:expect([[
  543. {1:<<<} lots ^of text with lots of text with |
  544. lots of text with lots of text with lots|
  545. of text with lots of text with lots of |
  546. text with lots of text with lots of text|
  547. with lots of text with lots of text wit|
  548. |
  549. ]])
  550. -- scrolling down, cursor moves screen line up
  551. feed('5<C-Y>')
  552. screen:expect([[
  553. {1:<<<}th lots of text with lots of text wit|
  554. h lots of text with lots of text with lo|
  555. ts of text with lots of text with lots o|
  556. f text with lots of text with lots of te|
  557. xt with l^ots of text with lots of text w|
  558. |
  559. ]])
  560. feed('<C-Y>')
  561. screen:expect([[
  562. Line with lots of text with lots of text|
  563. with lots of text with lots of text wit|
  564. h lots of text with lots of text with lo|
  565. ts of text with lots of text with lots o|
  566. f text wi^th lots of text with lots of te|
  567. |
  568. ]])
  569. -- 'scrolloff' set to 1, scrolling up, cursor moves screen line down
  570. exec('set scrolloff=1')
  571. feed('10|<C-E>')
  572. screen:expect([[
  573. {1:<<<}th lots of text with lots of text wit|
  574. h lots of^ text with lots of text with lo|
  575. ts of text with lots of text with lots o|
  576. f text with lots of text with lots of te|
  577. xt with lots of text with lots of text w|
  578. |
  579. ]])
  580. -- 'scrolloff' set to 1, scrolling down, cursor moves screen line up
  581. feed('<C-E>gjgj<C-Y>')
  582. screen:expect([[
  583. {1:<<<}th lots of text with lots of text wit|
  584. h lots of text with lots of text with lo|
  585. ts of text with lots of text with lots o|
  586. f text wi^th lots of text with lots of te|
  587. xt with lots of text with lots of text w|
  588. |
  589. ]])
  590. -- 'scrolloff' set to 2, scrolling up, cursor moves screen line down
  591. exec('set scrolloff=2')
  592. feed('10|<C-E>')
  593. screen:expect([[
  594. {1:<<<}th lots of text with lots of text wit|
  595. h lots of text with lots of text with lo|
  596. ts of tex^t with lots of text with lots o|
  597. f text with lots of text with lots of te|
  598. xt with lots of text with lots of text w|
  599. |
  600. ]])
  601. -- 'scrolloff' set to 2, scrolling down, cursor moves screen line up
  602. feed('<C-E>gj<C-Y>')
  603. screen:expect_unchanged()
  604. -- 'scrolloff' set to 0, move cursor down one line. Cursor should move properly,
  605. -- and since this is a really long line, it will be put on top of the screen.
  606. exec('set scrolloff=0')
  607. feed('0j')
  608. screen:expect([[
  609. {1:<<<}th lots of text with lots of text wit|
  610. h lots of text with lots of text with lo|
  611. ts of text with lots of text with lots o|
  612. f text with lots of text end |
  613. ^four |
  614. |
  615. ]])
  616. -- Test zt/zz/zb that they work properly when a long line is above it
  617. feed('zt')
  618. screen:expect([[
  619. ^four |
  620. {1:~ }|*4
  621. |
  622. ]])
  623. feed('zz')
  624. screen:expect([[
  625. {1:<<<}of text with lots of text with lots o|
  626. f text with lots of text end |
  627. ^four |
  628. {1:~ }|*2
  629. |
  630. ]])
  631. feed('zb')
  632. screen:expect([[
  633. {1:<<<}th lots of text with lots of text wit|
  634. h lots of text with lots of text with lo|
  635. ts of text with lots of text with lots o|
  636. f text with lots of text end |
  637. ^four |
  638. |
  639. ]])
  640. -- Repeat the step and move the cursor down again.
  641. -- This time, use a shorter long line that is barely long enough to span more
  642. -- than one window. Note that the cursor is at the bottom this time because
  643. -- Vim prefers to do so if we are scrolling a few lines only.
  644. exec(
  645. "call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(10)) .. ' end', 'four'])"
  646. )
  647. -- Currently visible lines were replaced, test that the lines and cursor
  648. -- are correctly displayed.
  649. screen:expect_unchanged()
  650. feed('3Gztj')
  651. screen:expect_unchanged()
  652. -- Repeat the step but this time start it when the line is smooth-scrolled by
  653. -- one line. This tests that the offset calculation is still correct and
  654. -- still end up scrolling down to the next line with cursor at bottom of
  655. -- screen.
  656. feed('3Gzt<C-E>j')
  657. screen:expect([[
  658. {1:<<<}th lots of text with lots of text wit|
  659. h lots of text with lots of text with lo|
  660. ts of text with lots of text with lots o|
  661. f text with lots of text end |
  662. fou^r |
  663. |
  664. ]])
  665. end)
  666. -- oldtest: Test_smoothscroll_one_long_line()
  667. it('scrolls correctly when moving the cursor', function()
  668. screen:try_resize(40, 6)
  669. exec([[
  670. call setline(1, 'with lots of text '->repeat(7))
  671. set smoothscroll scrolloff=0
  672. ]])
  673. local s1 = [[
  674. ^with lots of text with lots of text with|
  675. lots of text with lots of text with lot|
  676. s of text with lots of text with lots of|
  677. text |
  678. {1:~ }|
  679. |
  680. ]]
  681. screen:expect(s1)
  682. feed('<C-E>')
  683. screen:expect([[
  684. {1:<<<}ts of text with lots of text with lot|
  685. ^s of text with lots of text with lots of|
  686. text |
  687. {1:~ }|*2
  688. |
  689. ]])
  690. feed('0')
  691. screen:expect(s1)
  692. end)
  693. -- oldtest: Test_smoothscroll_long_line_showbreak()
  694. it('cursor is not one screen line too far down', function()
  695. screen:try_resize(40, 6)
  696. -- a line that spans four screen lines
  697. exec("call setline(1, 'with lots of text in one line '->repeat(6))")
  698. exec('set smoothscroll scrolloff=0 showbreak=+++\\ ')
  699. local s1 = [[
  700. ^with lots of text in one line with lots |
  701. {1:+++ }of text in one line with lots of tex|
  702. {1:+++ }t in one line with lots of text in o|
  703. {1:+++ }ne line with lots of text in one lin|
  704. {1:+++ }e with lots of text in one line |
  705. |
  706. ]]
  707. screen:expect(s1)
  708. feed('<C-E>')
  709. screen:expect([[
  710. {1:+++ }^of text in one line with lots of tex|
  711. {1:+++ }t in one line with lots of text in o|
  712. {1:+++ }ne line with lots of text in one lin|
  713. {1:+++ }e with lots of text in one line |
  714. {1:~ }|
  715. |
  716. ]])
  717. feed('0')
  718. screen:expect(s1)
  719. end)
  720. -- oldtest: Test_smoothscroll_marker_over_double_width_dump()
  721. it('marker is drawn over double-width char correctly', function()
  722. screen:try_resize(40, 6)
  723. exec([[
  724. call setline(1, 'a'->repeat(&columns) .. '口'->repeat(10))
  725. setlocal smoothscroll
  726. ]])
  727. screen:expect([[
  728. ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
  729. 口口口口口口口口口口 |
  730. {1:~ }|*3
  731. |
  732. ]])
  733. feed('<C-E>')
  734. screen:expect([[
  735. {1:<<<} 口口口口口口口^口 |
  736. {1:~ }|*4
  737. |
  738. ]])
  739. end)
  740. -- oldtest: Test_smoothscroll_zero_width()
  741. it('does not divide by zero with a narrow window', function()
  742. screen:try_resize(12, 2)
  743. exec([[
  744. call setline(1, ['a'->repeat(100)])
  745. set wrap smoothscroll number laststatus=0
  746. wincmd v
  747. wincmd v
  748. wincmd v
  749. wincmd v
  750. ]])
  751. screen:expect([[
  752. {8: 1^ }│{8: }│{8: }│{8: }│{8: }|
  753. |
  754. ]])
  755. feed('llllllllll<C-W>o')
  756. screen:expect([[
  757. {1:<<<}{8: }aa^aaaaaa|
  758. |
  759. ]])
  760. end)
  761. -- oldtest: Test_smoothscroll_ins_lines()
  762. it('does not unnecessarily insert lines', function()
  763. screen:try_resize(40, 6)
  764. exec([=[
  765. set wrap smoothscroll scrolloff=0 conceallevel=2 concealcursor=nc
  766. call setline(1, [
  767. \'line one' .. 'with lots of text in one line '->repeat(2),
  768. \'line two',
  769. \'line three',
  770. \'line four',
  771. \'line five'
  772. \])
  773. ]=])
  774. feed('<C-E>gjgk')
  775. screen:expect([[
  776. {1:<<<}lots of text in one line^ |
  777. line two |
  778. line three |
  779. line four |
  780. line five |
  781. |
  782. ]])
  783. end)
  784. -- oldtest: Test_smoothscroll_cursormoved_line()
  785. it('does not place the cursor in the command line', function()
  786. screen:try_resize(40, 6)
  787. exec([=[
  788. set smoothscroll
  789. call setline(1, [
  790. \'',
  791. \'_'->repeat(&lines * &columns),
  792. \(('_')->repeat(&columns - 2) .. 'xxx')->repeat(2)
  793. \])
  794. autocmd CursorMoved * eval [line('w0'), line('w$')]
  795. call search('xxx')
  796. ]=])
  797. screen:expect([[
  798. {1:<<<}_____________________________________|
  799. ________________________________________|
  800. ______________________________________^xx|
  801. x______________________________________x|
  802. xx |
  803. |
  804. ]])
  805. end)
  806. -- oldtest: Test_smoothscroll_eob()
  807. it('does not scroll halfway at end of buffer', function()
  808. screen:try_resize(40, 10)
  809. exec([[
  810. set smoothscroll
  811. call setline(1, ['']->repeat(100))
  812. norm G
  813. ]])
  814. -- does not scroll halfway when scrolling to end of buffer
  815. screen:expect([[
  816. |*8
  817. ^ |
  818. |
  819. ]])
  820. exec("call setline(92, 'a'->repeat(100))")
  821. feed('<C-L><C-B>G')
  822. -- cursor is not placed below window
  823. screen:expect([[
  824. {1:<<<}aaaaaaaaaaaaaaaaa |
  825. |*7
  826. ^ |
  827. |
  828. ]])
  829. end)
  830. -- oldtest: Test_smoothscroll_incsearch()
  831. it('does not reset skipcol when doing incremental search on the same word', function()
  832. screen:try_resize(40, 8)
  833. exec([[
  834. set smoothscroll number scrolloff=0 incsearch
  835. call setline(1, repeat([''], 20))
  836. call setline(11, repeat('a', 100))
  837. call setline(14, 'bbbb')
  838. ]])
  839. feed('/b')
  840. screen:expect([[
  841. {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa |
  842. {8: 12 } |
  843. {8: 13 } |
  844. {8: 14 }{2:b}{10:bbb} |
  845. {8: 15 } |
  846. {8: 16 } |
  847. {8: 17 } |
  848. /b^ |
  849. ]])
  850. feed('b')
  851. screen:expect([[
  852. {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa |
  853. {8: 12 } |
  854. {8: 13 } |
  855. {8: 14 }{2:bb}{10:bb} |
  856. {8: 15 } |
  857. {8: 16 } |
  858. {8: 17 } |
  859. /bb^ |
  860. ]])
  861. feed('b')
  862. screen:expect([[
  863. {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa |
  864. {8: 12 } |
  865. {8: 13 } |
  866. {8: 14 }{2:bbb}b |
  867. {8: 15 } |
  868. {8: 16 } |
  869. {8: 17 } |
  870. /bbb^ |
  871. ]])
  872. feed('b')
  873. screen:expect([[
  874. {1:<<<}{8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaa |
  875. {8: 12 } |
  876. {8: 13 } |
  877. {8: 14 }{2:bbbb} |
  878. {8: 15 } |
  879. {8: 16 } |
  880. {8: 17 } |
  881. /bbbb^ |
  882. ]])
  883. end)
  884. -- oldtest: Test_smoothscroll_multi_skipcol()
  885. it('scrolling multiple lines and stopping at non-zero skipcol', function()
  886. screen:try_resize(40, 10)
  887. exec([[
  888. setlocal cursorline scrolloff=0 smoothscroll
  889. call setline(1, repeat([''], 8))
  890. call setline(3, repeat('a', 50))
  891. call setline(4, repeat('a', 50))
  892. call setline(7, 'bbb')
  893. call setline(8, 'ccc')
  894. redraw
  895. ]])
  896. screen:expect([[
  897. {21:^ }|
  898. |
  899. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
  900. aaaaaaaaaa |
  901. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
  902. aaaaaaaaaa |
  903. |*2
  904. bbb |
  905. |
  906. ]])
  907. feed('3<C-E>')
  908. screen:expect([[
  909. {1:<<<}{21:aaaaaa^a }|
  910. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
  911. aaaaaaaaaa |
  912. |*2
  913. bbb |
  914. ccc |
  915. {1:~ }|*2
  916. |
  917. ]])
  918. feed('2<C-E>')
  919. screen:expect([[
  920. {1:<<<}{21:aaaaaa^a }|
  921. |*2
  922. bbb |
  923. ccc |
  924. {1:~ }|*4
  925. |
  926. ]])
  927. end)
  928. -- oldtest: Test_smoothscroll_zero_width_scroll_cursor_bot()
  929. it('does not divide by zero in zero-width window', function()
  930. screen:try_resize(40, 19)
  931. exec([[
  932. silent normal yy
  933. silent normal 19p
  934. set cpoptions+=n
  935. vsplit
  936. vertical resize 0
  937. set foldcolumn=1
  938. set number
  939. set smoothscroll
  940. silent normal 20G
  941. ]])
  942. screen:expect([[
  943. {8: }│ |
  944. {1:@}│ |*15
  945. {1:^@}│ |
  946. {3:< }{2:[No Name] [+] }|
  947. |
  948. ]])
  949. end)
  950. -- oldtest: Test_smoothscroll_cursor_top()
  951. it('resets skipcol when scrolling cursor to top', function()
  952. screen:try_resize(40, 12)
  953. exec([[
  954. set smoothscroll scrolloff=2
  955. new | 11resize | wincmd j
  956. call setline(1, ['line1', 'line2', 'line3'->repeat(20), 'line4'])
  957. exe "norm G3\<C-E>k"
  958. ]])
  959. screen:expect([[
  960. |
  961. {2:[No Name] }|
  962. line1 |
  963. line2 |
  964. ^line3line3line3line3line3line3line3line3|
  965. line3line3line3line3line3line3line3line3|
  966. line3line3line3line3 |
  967. line4 |
  968. {1:~ }|*2
  969. {3:[No Name] [+] }|
  970. |
  971. ]])
  972. end)
  973. -- oldtest: Test_smoothscroll_crash()
  974. it('does not crash with small window and cpo+=n', function()
  975. screen:try_resize(40, 12)
  976. exec([[
  977. 20 new
  978. vsp
  979. put =repeat('aaaa', 20)
  980. set nu fdc=1 smoothscroll cpo+=n
  981. vert resize 0
  982. exe "norm! 0\<c-e>"
  983. ]])
  984. feed('2<C-E>')
  985. assert_alive()
  986. end)
  987. -- oldtest: Test_smoothscroll_insert_bottom()
  988. it('works in Insert mode at bottom of window', function()
  989. screen:try_resize(40, 9)
  990. exec([[
  991. call setline(1, repeat([repeat('A very long line ...', 10)], 5))
  992. set wrap smoothscroll scrolloff=0
  993. ]])
  994. feed('Go123456789<CR>')
  995. screen:expect([[
  996. {1:<<<}ery long line ...A very long line ...|
  997. A very long line ...A very long line ...|*5
  998. 123456789 |
  999. ^ |
  1000. {5:-- INSERT --} |
  1001. ]])
  1002. end)
  1003. -- oldtest: Test_smoothscroll_in_qf_window()
  1004. it('works in quickfix window when changing quickfix list', function()
  1005. screen:try_resize(60, 20)
  1006. exec([[
  1007. set nocompatible display=lastline
  1008. copen 5
  1009. setlocal number smoothscroll
  1010. let g:l = [{'text': 'foo'}] + repeat([{'text': join(range(30))}], 10)
  1011. call setqflist(g:l, 'r')
  1012. normal! G
  1013. wincmd t
  1014. let g:l1 = [{'text': join(range(1000))}]
  1015. ]])
  1016. screen:expect([[
  1017. ^ |
  1018. {1:~ }|*11
  1019. {3:[No Name] }|
  1020. {1:<<<}{8: }21 22 23 24 25 26 27 28 29 |
  1021. {8: 10 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
  1022. {8: }21 22 23 24 25 26 27 28 29 |
  1023. {8: 11 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
  1024. {8: }21 22 23 24 25 26 27 28 29 |
  1025. {2:[Quickfix List] }|
  1026. |
  1027. ]])
  1028. feed([[:call setqflist([], 'r')<CR>]])
  1029. local screen_empty = [[
  1030. ^ |
  1031. {1:~ }|*11
  1032. {3:[No Name] }|
  1033. {8: 1 } |
  1034. {1:~ }|*4
  1035. {2:[Quickfix List] }|
  1036. :call setqflist([], 'r') |
  1037. ]]
  1038. screen:expect(screen_empty)
  1039. feed([[:call setqflist(g:l, 'r')<CR>]])
  1040. local screen_l_top = [[
  1041. ^ |
  1042. {1:~ }|*11
  1043. {3:[No Name] }|
  1044. {8: 1 }{10:|| foo }|
  1045. {8: 2 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
  1046. {8: }21 22 23 24 25 26 27 28 29 |
  1047. {8: 3 }|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
  1048. {8: }21 22 23 24 25 26 27 28 29 |
  1049. {2:[Quickfix List] }|
  1050. :call setqflist(g:l, 'r') |
  1051. ]]
  1052. screen:expect(screen_l_top)
  1053. feed([[:call setqflist(g:l1, 'r')<CR>]])
  1054. local screen_l1_top = [[
  1055. ^ |
  1056. {1:~ }|*11
  1057. {3:[No Name] }|
  1058. {8: 1 }{10:|| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 }|
  1059. {8: }{10:21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39}|
  1060. {8: }{10: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 5}|
  1061. {8: }{10:8 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 }|
  1062. {8: }{10:77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95}|
  1063. {2:[Quickfix List] }|
  1064. :call setqflist(g:l1, 'r') |
  1065. ]]
  1066. screen:expect(screen_l1_top)
  1067. feed('<C-W>b$<C-W>t')
  1068. local screen_l1_bot = [[
  1069. ^ |
  1070. {1:~ }|*11
  1071. {3:[No Name] }|
  1072. {1:<<<}{8: }{10: 937 938 939 940 941 942 943 944 945 946 947 948 949 950}|
  1073. {8: }{10: 951 952 953 954 955 956 957 958 959 960 961 962 963 964}|
  1074. {8: }{10: 965 966 967 968 969 970 971 972 973 974 975 976 977 978}|
  1075. {8: }{10: 979 980 981 982 983 984 985 986 987 988 989 990 991 992}|
  1076. {8: }{10: 993 994 995 996 997 998 999 }|
  1077. {2:[Quickfix List] }|
  1078. :call setqflist(g:l1, 'r') |
  1079. ]]
  1080. screen:expect(screen_l1_bot)
  1081. feed([[:call setqflist([], 'r')<CR>]])
  1082. screen:expect(screen_empty)
  1083. feed([[:call setqflist(g:l1, 'r')<CR>]])
  1084. screen:expect(screen_l1_top)
  1085. feed('<C-W>b$<C-W>t')
  1086. screen:expect(screen_l1_bot)
  1087. feed([[:call setqflist(g:l, 'r')<CR>]])
  1088. screen:expect(screen_l_top)
  1089. end)
  1090. it('works with virt_lines above and below', function()
  1091. screen:try_resize(55, 7)
  1092. exec([=[
  1093. call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(3))
  1094. set smoothscroll
  1095. let ns = nvim_create_namespace('')
  1096. call nvim_buf_set_extmark(0, ns, 0, 0, {'virt_lines':[[['virt_below1']]]})
  1097. call nvim_buf_set_extmark(0, ns, 1, 0, {'virt_lines':[[['virt_above1']]],'virt_lines_above':1})
  1098. call nvim_buf_set_extmark(0, ns, 1, 0, {'virt_lines':[[['virt_below2']]]})
  1099. call nvim_buf_set_extmark(0, ns, 2, 0, {'virt_lines':[[['virt_above2']]],'virt_lines_above':1})
  1100. norm ggL
  1101. ]=])
  1102. screen:expect([[
  1103. Line with some text with some text with some text with |
  1104. some text with some text with some text with some text |
  1105. virt_below1 |
  1106. virt_above1 |
  1107. ^Line with some text with some text with some text with |
  1108. some text with some text with some text with some text |
  1109. |
  1110. ]])
  1111. feed('<C-E>')
  1112. screen:expect([[
  1113. {1:<<<}e text with some text with some text with some text |
  1114. virt_below1 |
  1115. virt_above1 |
  1116. ^Line with some text with some text with some text with |
  1117. some text with some text with some text with some text |
  1118. virt_below2 |
  1119. |
  1120. ]])
  1121. feed('<C-E>')
  1122. screen:expect([[
  1123. virt_below1 |
  1124. virt_above1 |
  1125. ^Line with some text with some text with some text with |
  1126. some text with some text with some text with some text |
  1127. virt_below2 |
  1128. virt_above2 |
  1129. |
  1130. ]])
  1131. feed('<C-E>')
  1132. screen:expect([[
  1133. virt_above1 |
  1134. ^Line with some text with some text with some text with |
  1135. some text with some text with some text with some text |
  1136. virt_below2 |
  1137. virt_above2 |
  1138. Line with some text with some text with some text wi{1:@@@}|
  1139. |
  1140. ]])
  1141. feed('<C-E>')
  1142. screen:expect([[
  1143. ^Line with some text with some text with some text with |
  1144. some text with some text with some text with some text |
  1145. virt_below2 |
  1146. virt_above2 |
  1147. Line with some text with some text with some text with |
  1148. some text with some text with some text with some text |
  1149. |
  1150. ]])
  1151. feed('<C-E>')
  1152. screen:expect([[
  1153. {1:<<<}e text with some text with some text with some tex^t |
  1154. virt_below2 |
  1155. virt_above2 |
  1156. Line with some text with some text with some text with |
  1157. some text with some text with some text with some text |
  1158. {1:~ }|
  1159. |
  1160. ]])
  1161. end)
  1162. it('<<< marker shows with tabline, winbar and splits', function()
  1163. screen:try_resize(40, 12)
  1164. screen:set_default_attr_ids({
  1165. [1] = { foreground = Screen.colors.Blue1, bold = true },
  1166. [2] = { reverse = true },
  1167. [3] = { bold = true, reverse = true },
  1168. [4] = { background = Screen.colors.LightMagenta },
  1169. [5] = { bold = true },
  1170. [31] = { foreground = Screen.colors.Fuchsia, bold = true },
  1171. })
  1172. exec([[
  1173. call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
  1174. set smoothscroll scrolloff=0
  1175. norm sj
  1176. ]])
  1177. screen:expect([[
  1178. {1:<<<}e text with some text with some text |
  1179. with some text with some text |
  1180. Line with some text with some text with |
  1181. some text with some text with some text |
  1182. with some text with some text |
  1183. {2:[No Name] [+] }|
  1184. {1:<<<}e text with some text with some text |
  1185. ^with some text with some text |
  1186. Line with some text with some text with |
  1187. some text with some text with some te{1:@@@}|
  1188. {3:[No Name] [+] }|
  1189. |
  1190. ]])
  1191. exec('set showtabline=2')
  1192. feed('<C-E>')
  1193. screen:expect([[
  1194. {5: }{31:2}{5:+ [No Name] }{2: }|
  1195. {1:<<<}e text with some text with some text |
  1196. with some text with some text |
  1197. Line with some text with some text with |
  1198. some text with some text with some text |
  1199. with some text with some text |
  1200. {2:[No Name] [+] }|
  1201. {1:<<<}e text with some text with some text |
  1202. ^with some text with some text |
  1203. Line with some text with some text wi{1:@@@}|
  1204. {3:[No Name] [+] }|
  1205. |
  1206. ]])
  1207. exec('set winbar=winbar')
  1208. feed('<C-w>k<C-E>')
  1209. screen:expect([[
  1210. {5: }{31:2}{5:+ [No Name] }{2: }|
  1211. {5:winbar }|
  1212. {1:<<<}e text with some text with some text |
  1213. ^with some text with some text |
  1214. Line with some text with some text with |
  1215. some text with some text with some te{1:@@@}|
  1216. {3:[No Name] [+] }|
  1217. {5:winbar }|
  1218. {1:<<<}e text with some text with some text |
  1219. with some text with some text |
  1220. {2:[No Name] [+] }|
  1221. |
  1222. ]])
  1223. end)
  1224. it('works with very long line', function()
  1225. exec([[
  1226. edit test/functional/fixtures/bigfile_oneline.txt
  1227. setlocal smoothscroll number
  1228. ]])
  1229. screen:expect([[
  1230. {8: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;|
  1231. {8: }; 0001;<control>;Cc;0;BN;;;;;N;START|
  1232. {8: } OF HEADING;;;; 0002;<control>;Cc;0;|
  1233. {8: }BN;;;;;N;START OF TEXT;;;; 0003;<con|
  1234. {8: }trol>;Cc;0;BN;;;;;N;END OF TEXT;;;; |
  1235. {8: }0004;<control>;Cc;0;BN;;;;;N;END OF |
  1236. {8: }TRANSMISSION;;;; 0005;<control>;Cc;0|
  1237. {8: };BN;;;;;N;ENQUIRY;;;; 0006;<control>|
  1238. {8: };Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; 0007;|
  1239. {8: }<control>;Cc;0;BN;;;;;N;BELL;;;; 000|
  1240. {8: }8;<control>;Cc;0;BN;;;;;N;BACKSPACE;|
  1241. |
  1242. ]])
  1243. feed('j')
  1244. screen:expect([[
  1245. {1:<<<}{8: }CJK COMPATIBILITY IDEOGRAPH-2F91F;Lo|
  1246. {8: };0;L;243AB;;;;N;;;;; 2F920;CJK COMPA|
  1247. {8: }TIBILITY IDEOGRAPH-2F920;Lo;0;L;7228|
  1248. {8: };;;;N;;;;; 2F921;CJK COMPATIBILITY I|
  1249. {8: }DEOGRAPH-2F921;Lo;0;L;7235;;;;N;;;;;|
  1250. {8: } 2F922;CJK COMPATIBILITY IDEOGRAPH-2|
  1251. {8: }F922;Lo;0;L;7250;;;;N;;;;; |
  1252. {8: 2 }^2F923;CJK COMPATIBILITY IDEOGRAPH-2F|
  1253. {8: }923;Lo;0;L;24608;;;;N;;;;; |
  1254. {8: 3 }2F924;CJK COMPATIBILITY IDEOGRAPH-2F|
  1255. {8: }924;Lo;0;L;7280;;;;N;;;;; |
  1256. |
  1257. ]])
  1258. end)
  1259. it('works with very long line and scrolloff', function()
  1260. screen:try_resize(40, 8)
  1261. exec([[
  1262. set smoothscroll scrolloff=3
  1263. call setline(1, ['one', 'two long '->repeat(100), 'three', 'four', 'five', 'six'])
  1264. ]])
  1265. feed(':norm j721|<CR>')
  1266. screen:expect([[
  1267. {1:<<<}two long two long two long two long t|
  1268. wo long two long two long two long two l|
  1269. ong two long two long two long two long |
  1270. ^two long two long two long two long two |
  1271. long two long two long two long two long|
  1272. two long two long two long two long two|
  1273. long two long two long two long two lon|
  1274. :norm j721| |
  1275. ]])
  1276. feed('gj')
  1277. screen:expect([[
  1278. {1:<<<}two long two long two long two long t|
  1279. wo long two long two long two long two l|
  1280. ong two long two long two long two long |
  1281. two long two long two long two long two |
  1282. ^long two long two long two long two long|
  1283. two long two long two long two long two|
  1284. long two long two long two long two lon|
  1285. :norm j721| |
  1286. ]])
  1287. feed('gj')
  1288. screen:expect([[
  1289. {1:<<<}long two long two long two long two l|
  1290. ong two long two long two long two long |
  1291. two long two long two long two long two |
  1292. long two long two long two long two long|
  1293. ^ two long two long two long two long two|
  1294. long two long two long two long two lon|
  1295. g two long two long |
  1296. :norm j721| |
  1297. ]])
  1298. feed('gj')
  1299. screen:expect([[
  1300. {1:<<<}long two long two long two long two l|
  1301. ong two long two long two long two long |
  1302. two long two long two long two long two |
  1303. long two long two long two long two long|
  1304. two long two long two long two long two|
  1305. ^ long two long two long two long two lon|
  1306. g two long two long |
  1307. :norm j721| |
  1308. ]])
  1309. feed('gj')
  1310. screen:expect([[
  1311. {1:<<<}long two long two long two long two l|
  1312. ong two long two long two long two long |
  1313. two long two long two long two long two |
  1314. long two long two long two long two long|
  1315. two long two long two long two long two|
  1316. long two long two long two long two lon|
  1317. ^g two long two long |
  1318. :norm j721| |
  1319. ]])
  1320. feed('gj')
  1321. screen:expect([[
  1322. {1:<<<} long two long two long two long two |
  1323. long two long two long two long two long|
  1324. two long two long two long two long two|
  1325. long two long two long two long two lon|
  1326. g two long two long |
  1327. ^three |
  1328. four |
  1329. :norm j721| |
  1330. ]])
  1331. feed('gk')
  1332. screen:expect([[
  1333. {1:<<<}long two long two long two long two l|
  1334. ong two long two long two long two long |
  1335. two long two long two long two long two |
  1336. long two long two long two long two long|
  1337. two long two long two long two long two|
  1338. long two long two long two long two lon|
  1339. ^g two long two long |
  1340. :norm j721| |
  1341. ]])
  1342. end)
  1343. end)