scroll_opt_spec.lua 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382
  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:add_extra_attr_ids {
  1165. [100] = { foreground = Screen.colors.Magenta1, bold = true },
  1166. }
  1167. exec([[
  1168. call setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
  1169. set smoothscroll scrolloff=0
  1170. norm sj
  1171. ]])
  1172. screen:expect([[
  1173. {1:<<<}e text with some text with some text |
  1174. with some text with some text |
  1175. Line with some text with some text with |
  1176. some text with some text with some text |
  1177. with some text with some text |
  1178. {2:[No Name] [+] }|
  1179. {1:<<<}e text with some text with some text |
  1180. ^with some text with some text |
  1181. Line with some text with some text with |
  1182. some text with some text with some te{1:@@@}|
  1183. {3:[No Name] [+] }|
  1184. |
  1185. ]])
  1186. exec('set showtabline=2')
  1187. feed('<C-E>')
  1188. screen:expect([[
  1189. {5: }{100:2}{5:+ [No Name] }{2: }|
  1190. {1:<<<}e text with some text with some text |
  1191. with some text with some text |
  1192. Line with some text with some text with |
  1193. some text with some text with some text |
  1194. with some text with some text |
  1195. {2:[No Name] [+] }|
  1196. {1:<<<}e text with some text with some text |
  1197. ^with some text with some text |
  1198. Line with some text with some text wi{1:@@@}|
  1199. {3:[No Name] [+] }|
  1200. |
  1201. ]])
  1202. exec('set winbar=winbar')
  1203. feed('<C-w>k<C-E>')
  1204. screen:expect([[
  1205. {5: }{100:2}{5:+ [No Name] }{2: }|
  1206. {5:winbar }|
  1207. {1:<<<}e text with some text with some text |
  1208. ^with some text with some text |
  1209. Line with some text with some text with |
  1210. some text with some text with some te{1:@@@}|
  1211. {3:[No Name] [+] }|
  1212. {5:winbar }|
  1213. {1:<<<}e text with some text with some text |
  1214. with some text with some text |
  1215. {2:[No Name] [+] }|
  1216. |
  1217. ]])
  1218. end)
  1219. it('works with very long line', function()
  1220. exec([[
  1221. edit test/functional/fixtures/bigfile_oneline.txt
  1222. setlocal smoothscroll number
  1223. ]])
  1224. screen:expect([[
  1225. {8: 1 }^0000;<control>;Cc;0;BN;;;;;N;NULL;;;|
  1226. {8: }; 0001;<control>;Cc;0;BN;;;;;N;START|
  1227. {8: } OF HEADING;;;; 0002;<control>;Cc;0;|
  1228. {8: }BN;;;;;N;START OF TEXT;;;; 0003;<con|
  1229. {8: }trol>;Cc;0;BN;;;;;N;END OF TEXT;;;; |
  1230. {8: }0004;<control>;Cc;0;BN;;;;;N;END OF |
  1231. {8: }TRANSMISSION;;;; 0005;<control>;Cc;0|
  1232. {8: };BN;;;;;N;ENQUIRY;;;; 0006;<control>|
  1233. {8: };Cc;0;BN;;;;;N;ACKNOWLEDGE;;;; 0007;|
  1234. {8: }<control>;Cc;0;BN;;;;;N;BELL;;;; 000|
  1235. {8: }8;<control>;Cc;0;BN;;;;;N;BACKSPACE;|
  1236. |
  1237. ]])
  1238. feed('j')
  1239. screen:expect([[
  1240. {1:<<<}{8: }CJK COMPATIBILITY IDEOGRAPH-2F91F;Lo|
  1241. {8: };0;L;243AB;;;;N;;;;; 2F920;CJK COMPA|
  1242. {8: }TIBILITY IDEOGRAPH-2F920;Lo;0;L;7228|
  1243. {8: };;;;N;;;;; 2F921;CJK COMPATIBILITY I|
  1244. {8: }DEOGRAPH-2F921;Lo;0;L;7235;;;;N;;;;;|
  1245. {8: } 2F922;CJK COMPATIBILITY IDEOGRAPH-2|
  1246. {8: }F922;Lo;0;L;7250;;;;N;;;;; |
  1247. {8: 2 }^2F923;CJK COMPATIBILITY IDEOGRAPH-2F|
  1248. {8: }923;Lo;0;L;24608;;;;N;;;;; |
  1249. {8: 3 }2F924;CJK COMPATIBILITY IDEOGRAPH-2F|
  1250. {8: }924;Lo;0;L;7280;;;;N;;;;; |
  1251. |
  1252. ]])
  1253. end)
  1254. it('works with very long line and scrolloff', function()
  1255. screen:try_resize(40, 8)
  1256. exec([[
  1257. set smoothscroll scrolloff=3
  1258. call setline(1, ['one', 'two long '->repeat(100), 'three', 'four', 'five', 'six'])
  1259. ]])
  1260. feed(':norm j721|<CR>')
  1261. screen:expect([[
  1262. {1:<<<}two long two long two long two long t|
  1263. wo long two long two long two long two l|
  1264. ong two long two long two long two long |
  1265. ^two long two long two long two long two |
  1266. long two long two long two long two long|
  1267. two long two long two long two long two|
  1268. long two long two long two long two lon|
  1269. :norm j721| |
  1270. ]])
  1271. feed('gj')
  1272. screen:expect([[
  1273. {1:<<<}two long two long two long two long t|
  1274. wo long two long two long two long two l|
  1275. ong two long two long two long two long |
  1276. two long two long two long two long two |
  1277. ^long two long two long two long two long|
  1278. two long two long two long two long two|
  1279. long two long two long two long two lon|
  1280. :norm j721| |
  1281. ]])
  1282. feed('gj')
  1283. screen:expect([[
  1284. {1:<<<}long two long two long two long two l|
  1285. ong two long two long two long two long |
  1286. two long two long two long two long two |
  1287. long two long two long two long two long|
  1288. ^ two long two long two long two long two|
  1289. long two long two long two long two lon|
  1290. g two long two long |
  1291. :norm j721| |
  1292. ]])
  1293. feed('gj')
  1294. screen:expect([[
  1295. {1:<<<}long two long two long two long two l|
  1296. ong two long two long two long two long |
  1297. two long two long two long two long two |
  1298. long two long two long two long two long|
  1299. two long two long two long two long two|
  1300. ^ long two long two long two long two lon|
  1301. g two long two long |
  1302. :norm j721| |
  1303. ]])
  1304. feed('gj')
  1305. screen:expect([[
  1306. {1:<<<}long two long two long two long two l|
  1307. ong two long two long two long two long |
  1308. two long two long two long two long two |
  1309. long two long two long two long two long|
  1310. two long two long two long two long two|
  1311. long two long two long two long two lon|
  1312. ^g two long two long |
  1313. :norm j721| |
  1314. ]])
  1315. feed('gj')
  1316. screen:expect([[
  1317. {1:<<<} long two long two long two long two |
  1318. long two long two long two long two long|
  1319. two long two long two long two long two|
  1320. long two long two long two long two lon|
  1321. g two long two long |
  1322. ^three |
  1323. four |
  1324. :norm j721| |
  1325. ]])
  1326. feed('gk')
  1327. screen:expect([[
  1328. {1:<<<}long two long two long two long two l|
  1329. ong two long two long two long two long |
  1330. two long two long two long two long two |
  1331. long two long two long two long two long|
  1332. two long two long two long two long two|
  1333. long two long two long two long two lon|
  1334. ^g two long two long |
  1335. :norm j721| |
  1336. ]])
  1337. end)
  1338. end)