screen_basic_spec.lua 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local Screen = require('test.functional.ui.screen')
  4. local set_session, clear = n.set_session, n.clear
  5. local feed, command = n.feed, n.command
  6. local exec = n.exec
  7. local insert = n.insert
  8. local eq = t.eq
  9. local fn, api = n.fn, n.api
  10. describe('screen', function()
  11. local screen
  12. local nvim_argv = {
  13. n.nvim_prog,
  14. '-u',
  15. 'NONE',
  16. '-i',
  17. 'NONE',
  18. '-n',
  19. '--cmd',
  20. 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
  21. '--cmd',
  22. 'colorscheme vim',
  23. '--embed',
  24. }
  25. before_each(function()
  26. local screen_nvim = n.new_session(false, { args = nvim_argv, merge = false })
  27. set_session(screen_nvim)
  28. screen = Screen.new()
  29. end)
  30. it('default initial screen', function()
  31. screen:expect([[
  32. ^ |
  33. {1:~ }|*11
  34. {3:[No Name] }|
  35. |
  36. ]])
  37. end)
  38. end)
  39. local function screen_tests(linegrid)
  40. local screen
  41. before_each(function()
  42. clear()
  43. screen = Screen.new(53, 14, { rgb = true, ext_linegrid = linegrid })
  44. screen:set_default_attr_ids({
  45. [0] = { bold = true, foreground = 255 },
  46. [1] = { bold = true, reverse = true },
  47. [2] = { bold = true },
  48. [3] = { reverse = true },
  49. [4] = { background = Screen.colors.LightGrey, underline = true },
  50. [5] = {
  51. background = Screen.colors.LightGrey,
  52. underline = true,
  53. bold = true,
  54. foreground = Screen.colors.Fuchsia,
  55. },
  56. [6] = { bold = true, foreground = Screen.colors.Fuchsia },
  57. [7] = { bold = true, foreground = Screen.colors.SeaGreen },
  58. [8] = { foreground = Screen.colors.White, background = Screen.colors.Red },
  59. })
  60. end)
  61. describe('bell/visual bell', function()
  62. it('is forwarded to the UI', function()
  63. feed('<left>')
  64. screen:expect(function()
  65. eq(true, screen.bell)
  66. eq(false, screen.visual_bell)
  67. end)
  68. screen.bell = false
  69. command('set visualbell')
  70. feed('<left>')
  71. screen:expect(function()
  72. eq(true, screen.visual_bell)
  73. eq(false, screen.bell)
  74. end)
  75. end)
  76. end)
  77. describe(':set title', function()
  78. it('is forwarded to the UI', function()
  79. local expected = 'test-title'
  80. command('set titlestring=' .. expected)
  81. command('set title')
  82. screen:expect(function()
  83. eq(expected, screen.title)
  84. end)
  85. screen:detach()
  86. screen.title = nil
  87. screen:attach()
  88. screen:expect(function()
  89. eq(expected, screen.title)
  90. end)
  91. end)
  92. end)
  93. describe(':set icon', function()
  94. it('is forwarded to the UI', function()
  95. local expected = 'test-icon'
  96. command('set iconstring=' .. expected)
  97. command('set icon')
  98. screen:expect(function()
  99. eq(expected, screen.icon)
  100. end)
  101. screen:detach()
  102. screen.icon = nil
  103. screen:attach()
  104. screen:expect(function()
  105. eq(expected, screen.icon)
  106. end)
  107. end)
  108. end)
  109. describe('statusline', function()
  110. it('is redrawn after <c-l>', function()
  111. command('set laststatus=2')
  112. screen:expect([[
  113. ^ |
  114. {0:~ }|*11
  115. {1:[No Name] }|
  116. |
  117. ]])
  118. feed('<c-l>')
  119. screen:expect {
  120. grid = [[
  121. ^ |
  122. {0:~ }|*11
  123. {1:[No Name] }|
  124. |
  125. ]],
  126. reset = true,
  127. }
  128. command('split')
  129. screen:expect([[
  130. ^ |
  131. {0:~ }|*5
  132. {1:[No Name] }|
  133. |
  134. {0:~ }|*4
  135. {3:[No Name] }|
  136. |
  137. ]])
  138. feed('<c-l>')
  139. screen:expect {
  140. grid = [[
  141. ^ |
  142. {0:~ }|*5
  143. {1:[No Name] }|
  144. |
  145. {0:~ }|*4
  146. {3:[No Name] }|
  147. |
  148. ]],
  149. reset = true,
  150. }
  151. end)
  152. end)
  153. describe('window', function()
  154. describe('split', function()
  155. it('horizontal', function()
  156. command('sp')
  157. screen:expect([[
  158. ^ |
  159. {0:~ }|*5
  160. {1:[No Name] }|
  161. |
  162. {0:~ }|*4
  163. {3:[No Name] }|
  164. |
  165. ]])
  166. end)
  167. it('horizontal and resize', function()
  168. command('sp')
  169. command('resize 8')
  170. screen:expect([[
  171. ^ |
  172. {0:~ }|*7
  173. {1:[No Name] }|
  174. |
  175. {0:~ }|*2
  176. {3:[No Name] }|
  177. |
  178. ]])
  179. end)
  180. it('horizontal and vertical', function()
  181. command('sp')
  182. command('vsp')
  183. command('vsp')
  184. screen:expect([[
  185. ^ │ │ |
  186. {0:~ }│{0:~ }│{0:~ }|*5
  187. {1:[No Name] }{3:[No Name] [No Name] }|
  188. |
  189. {0:~ }|*4
  190. {3:[No Name] }|
  191. |
  192. ]])
  193. insert('hello')
  194. screen:expect([[
  195. hell^o │hello │hello |
  196. {0:~ }│{0:~ }│{0:~ }|*5
  197. {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }|
  198. hello |
  199. {0:~ }|*4
  200. {3:[No Name] [+] }|
  201. |
  202. ]])
  203. end)
  204. end)
  205. end)
  206. describe('tabs', function()
  207. it('tabnew creates a new buffer', function()
  208. command('sp')
  209. command('vsp')
  210. command('vsp')
  211. insert('hello')
  212. screen:expect([[
  213. hell^o │hello │hello |
  214. {0:~ }│{0:~ }│{0:~ }|*5
  215. {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }|
  216. hello |
  217. {0:~ }|*4
  218. {3:[No Name] [+] }|
  219. |
  220. ]])
  221. command('tabnew')
  222. insert('hello2')
  223. feed('h')
  224. screen:expect([[
  225. {4: }{5:4}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}|
  226. hell^o2 |
  227. {0:~ }|*11
  228. |
  229. ]])
  230. command('tabprevious')
  231. screen:expect([[
  232. {2: }{6:4}{2:+ [No Name] }{4: + [No Name] }{3: }{4:X}|
  233. hell^o │hello │hello |
  234. {0:~ }│{0:~ }│{0:~ }|*5
  235. {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }|
  236. hello |
  237. {0:~ }|*3
  238. {3:[No Name] [+] }|
  239. |
  240. ]])
  241. end)
  242. it('tabline is redrawn after messages', function()
  243. command('tabnew')
  244. screen:expect([[
  245. {4: [No Name] }{2: [No Name] }{3: }{4:X}|
  246. ^ |
  247. {0:~ }|*11
  248. |
  249. ]])
  250. feed(':echo "' .. string.rep('x\\n', 11) .. '"<cr>')
  251. screen:expect([[
  252. {1: }|
  253. x |*11
  254. |
  255. {7:Press ENTER or type command to continue}^ |
  256. ]])
  257. feed('<cr>')
  258. screen:expect([[
  259. {4: [No Name] }{2: [No Name] }{3: }{4:X}|
  260. ^ |
  261. {0:~ }|*11
  262. |
  263. ]])
  264. feed(':echo "' .. string.rep('x\\n', 12) .. '"<cr>')
  265. screen:expect([[
  266. x |*12
  267. |
  268. {7:Press ENTER or type command to continue}^ |
  269. ]])
  270. feed('<cr>')
  271. screen:expect([[
  272. {4: [No Name] }{2: [No Name] }{3: }{4:X}|
  273. ^ |
  274. {0:~ }|*11
  275. |
  276. ]])
  277. end)
  278. it('redraws properly with :tab split right after scroll', function()
  279. feed('15Ofoo<esc>15Obar<esc>gg')
  280. command('vsplit')
  281. screen:expect([[
  282. ^foo │foo |
  283. foo │foo |*11
  284. {1:[No Name] [+] }{3:[No Name] [+] }|
  285. |
  286. ]])
  287. feed('<PageDown>')
  288. screen:expect([[
  289. ^foo │foo |
  290. foo │foo |*3
  291. bar │foo |*8
  292. {1:[No Name] [+] }{3:[No Name] [+] }|
  293. |
  294. ]])
  295. command('tab split')
  296. screen:expect([[
  297. {4: }{5:2}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}|
  298. ^foo |
  299. foo |*3
  300. bar |*8
  301. |
  302. ]])
  303. end)
  304. it('redraws unvisited tab #9152', function()
  305. insert('hello')
  306. -- create a tab without visiting it
  307. command('tabnew|tabnext')
  308. screen:expect([[
  309. {2: + [No Name] }{4: [No Name] }{3: }{4:X}|
  310. hell^o |
  311. {0:~ }|*11
  312. |
  313. ]])
  314. feed('gT')
  315. screen:expect([[
  316. {4: + [No Name] }{2: [No Name] }{3: }{4:X}|
  317. ^ |
  318. {0:~ }|*11
  319. |
  320. ]])
  321. end)
  322. end)
  323. describe('insert mode', function()
  324. it('move to next line with <cr>', function()
  325. feed('iline 1<cr>line 2<cr>')
  326. screen:expect([[
  327. line 1 |
  328. line 2 |
  329. ^ |
  330. {0:~ }|*10
  331. {2:-- INSERT --} |
  332. ]])
  333. end)
  334. end)
  335. describe('normal mode', function()
  336. -- https://code.google.com/p/vim/issues/detail?id=339
  337. it("setting 'ruler' doesn't reset the preferred column", function()
  338. command('set virtualedit=')
  339. feed('i0123456<cr>789<esc>kllj')
  340. command('set ruler')
  341. feed('k')
  342. screen:expect([[
  343. 0123^456 |
  344. 789 |
  345. {0:~ }|*11
  346. 1,5 All |
  347. ]])
  348. end)
  349. end)
  350. describe('command mode', function()
  351. it('typing commands', function()
  352. feed(':ls')
  353. screen:expect([[
  354. |
  355. {0:~ }|*12
  356. :ls^ |
  357. ]])
  358. end)
  359. it('execute command with multi-line output', function()
  360. feed(':ls<cr>')
  361. screen:expect([[
  362. |
  363. {0:~ }|*9
  364. {1: }|
  365. :ls |
  366. 1 %a "[No Name]" line 1 |
  367. {7:Press ENTER or type command to continue}^ |
  368. ]])
  369. feed('<cr>') -- skip the "Press ENTER..." state or tests will hang
  370. end)
  371. end)
  372. describe('scrolling and clearing', function()
  373. before_each(function()
  374. insert([[
  375. Inserting
  376. text
  377. with
  378. many
  379. lines
  380. to
  381. test
  382. scrolling
  383. and
  384. clearing
  385. in
  386. split
  387. windows
  388. ]])
  389. command('sp')
  390. command('vsp')
  391. command('vsp')
  392. screen:expect([[
  393. and │and │and |
  394. clearing │clearing │clearing |
  395. in │in │in |
  396. split │split │split |
  397. windows │windows │windows |
  398. ^ │ │ |
  399. {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }|
  400. clearing |
  401. in |
  402. split |
  403. windows |
  404. |
  405. {3:[No Name] [+] }|
  406. |
  407. ]])
  408. end)
  409. it('only affects the current scroll region', function()
  410. feed('6k')
  411. screen:expect([[
  412. ^scrolling │and │and |
  413. and │clearing │clearing |
  414. clearing │in │in |
  415. in │split │split |
  416. split │windows │windows |
  417. windows │ │ |
  418. {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }|
  419. clearing |
  420. in |
  421. split |
  422. windows |
  423. |
  424. {3:[No Name] [+] }|
  425. |
  426. ]])
  427. feed('<c-w>l')
  428. screen:expect([[
  429. scrolling │and │and |
  430. and │clearing │clearing |
  431. clearing │in │in |
  432. in │split │split |
  433. split │windows │windows |
  434. windows │^ │ |
  435. {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }|
  436. clearing |
  437. in |
  438. split |
  439. windows |
  440. |
  441. {3:[No Name] [+] }|
  442. |
  443. ]])
  444. feed('gg')
  445. screen:expect([[
  446. scrolling │^Inserting │and |
  447. and │text │clearing |
  448. clearing │with │in |
  449. in │many │split |
  450. split │lines │windows |
  451. windows │to │ |
  452. {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }|
  453. clearing |
  454. in |
  455. split |
  456. windows |
  457. |
  458. {3:[No Name] [+] }|
  459. |
  460. ]])
  461. feed('7j')
  462. screen:expect([[
  463. scrolling │with │and |
  464. and │many │clearing |
  465. clearing │lines │in |
  466. in │to │split |
  467. split │test │windows |
  468. windows │^scrolling │ |
  469. {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }|
  470. clearing |
  471. in |
  472. split |
  473. windows |
  474. |
  475. {3:[No Name] [+] }|
  476. |
  477. ]])
  478. feed('2j')
  479. screen:expect([[
  480. scrolling │lines │and |
  481. and │to │clearing |
  482. clearing │test │in |
  483. in │scrolling │split |
  484. split │and │windows |
  485. windows │^clearing │ |
  486. {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }|
  487. clearing |
  488. in |
  489. split |
  490. windows |
  491. |
  492. {3:[No Name] [+] }|
  493. |
  494. ]])
  495. feed('5k')
  496. screen:expect([[
  497. scrolling │^lines │and |
  498. and │to │clearing |
  499. clearing │test │in |
  500. in │scrolling │split |
  501. split │and │windows |
  502. windows │clearing │ |
  503. {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }|
  504. clearing |
  505. in |
  506. split |
  507. windows |
  508. |
  509. {3:[No Name] [+] }|
  510. |
  511. ]])
  512. feed('k')
  513. screen:expect([[
  514. scrolling │^many │and |
  515. and │lines │clearing |
  516. clearing │to │in |
  517. in │test │split |
  518. split │scrolling │windows |
  519. windows │and │ |
  520. {3:[No Name] [+] }{1:[No Name] [+] }{3:<Name] [+] }|
  521. clearing |
  522. in |
  523. split |
  524. windows |
  525. |
  526. {3:[No Name] [+] }|
  527. |
  528. ]])
  529. end)
  530. end)
  531. describe('resize', function()
  532. it('rebuilds the whole screen', function()
  533. screen:try_resize(25, 5)
  534. feed('iresize')
  535. screen:expect([[
  536. resize^ |
  537. {0:~ }|*3
  538. {2:-- INSERT --} |
  539. ]])
  540. end)
  541. it('has minimum width/height values', function()
  542. feed('iresize')
  543. screen:try_resize(1, 1)
  544. screen:expect([[
  545. resize^ |
  546. {2:-- INSERT --}|
  547. ]])
  548. feed('<esc>:ls')
  549. screen:expect([[
  550. resize |
  551. :ls^ |
  552. ]])
  553. end)
  554. it('VimResized autocommand does not cause invalid UI events #20692 #20759', function()
  555. screen:try_resize(25, 5)
  556. feed('iresize<Esc>')
  557. command([[autocmd VimResized * redrawtabline]])
  558. command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]])
  559. command([[autocmd VimResized * let g:echospace = v:echospace]])
  560. api.nvim_set_option_value('showtabline', 2, {})
  561. screen:expect([[
  562. {2: + [No Name] }{3: }|
  563. resiz^e |
  564. {0:~ }|*2
  565. |
  566. ]])
  567. screen:try_resize(30, 6)
  568. screen:expect([[
  569. {2: + [No Name] }{3: }|
  570. resiz^e |
  571. {0:~ }|*3
  572. |
  573. ]])
  574. eq(29, api.nvim_get_var('echospace'))
  575. end)
  576. it('messages from the same Ex command as resize are visible #22225', function()
  577. feed(':set columns=20 | call<CR>')
  578. screen:expect([[
  579. |*9
  580. {1: }|
  581. {8:E471: Argument requi}|
  582. {8:red} |
  583. {7:Press ENTER or type }|
  584. {7:command to continue}^ |
  585. ]])
  586. feed('<CR>')
  587. screen:expect([[
  588. ^ |
  589. {0:~ }|*12
  590. |
  591. ]])
  592. feed(':set columns=0<CR>')
  593. screen:expect([[
  594. |
  595. {0:~ }|*7
  596. {1: }|
  597. {8:E594: Need at least }|
  598. {8:12 columns: columns=}|
  599. {8:0} |
  600. {7:Press ENTER or type }|
  601. {7:command to continue}^ |
  602. ]])
  603. feed('<CR>')
  604. screen:expect([[
  605. ^ |
  606. {0:~ }|*12
  607. |
  608. ]])
  609. end)
  610. it('clamps &cmdheight for current tabpage', function()
  611. command('set cmdheight=10 laststatus=2')
  612. screen:expect([[
  613. ^ |
  614. {0:~ }|*2
  615. {1:[No Name] }|
  616. |*10
  617. ]])
  618. screen:try_resize(53, 8)
  619. screen:expect([[
  620. ^ |
  621. {1:[No Name] }|
  622. |*6
  623. ]])
  624. eq(6, api.nvim_get_option_value('cmdheight', {}))
  625. end)
  626. it('clamps &cmdheight for another tabpage #31380', function()
  627. command('tabnew')
  628. command('set cmdheight=9 laststatus=2')
  629. screen:expect([[
  630. {4: [No Name] }{2: [No Name] }{3: }{4:X}|
  631. ^ |
  632. {0:~ }|*2
  633. {1:[No Name] }|
  634. |*9
  635. ]])
  636. command('tabprev')
  637. screen:expect([[
  638. {2: [No Name] }{4: [No Name] }{3: }{4:X}|
  639. ^ |
  640. {0:~ }|*10
  641. {1:[No Name] }|
  642. |
  643. ]])
  644. screen:try_resize(53, 8)
  645. screen:expect([[
  646. {2: [No Name] }{4: [No Name] }{3: }{4:X}|
  647. ^ |
  648. {0:~ }|*4
  649. {1:[No Name] }|
  650. |
  651. ]])
  652. command('tabnext')
  653. screen:expect([[
  654. {4: [No Name] }{2: [No Name] }{3: }{4:X}|
  655. ^ |
  656. {1:[No Name] }|
  657. |*5
  658. ]])
  659. eq(5, api.nvim_get_option_value('cmdheight', {}))
  660. end)
  661. end)
  662. describe('press enter', function()
  663. it('does not crash on <F1> at “Press ENTER”', function()
  664. command('nnoremap <F1> :echo "TEST"<CR>')
  665. feed(':ls<CR>')
  666. screen:expect([[
  667. |
  668. {0:~ }|*9
  669. {1: }|
  670. :ls |
  671. 1 %a "[No Name]" line 1 |
  672. {7:Press ENTER or type command to continue}^ |
  673. ]])
  674. feed('<F1>')
  675. screen:expect([[
  676. ^ |
  677. {0:~ }|*12
  678. TEST |
  679. ]])
  680. end)
  681. end)
  682. -- Regression test for #8357
  683. it('does not have artifacts after temporary chars in insert mode', function()
  684. command('set timeoutlen=10000')
  685. command('inoremap jk <esc>')
  686. feed('ifooj')
  687. screen:expect([[
  688. foo^j |
  689. {0:~ }|*12
  690. {2:-- INSERT --} |
  691. ]])
  692. feed('k')
  693. screen:expect([[
  694. fo^o |
  695. {0:~ }|*12
  696. |
  697. ]])
  698. end)
  699. end
  700. describe('Screen (char-based)', function()
  701. screen_tests(false)
  702. end)
  703. describe('Screen (line-based)', function()
  704. screen_tests(true)
  705. end)
  706. describe('Screen default colors', function()
  707. local screen
  708. local function startup(light, termcolors)
  709. local extra = (light and ' background=light') or ''
  710. local nvim_argv = {
  711. n.nvim_prog,
  712. '-u',
  713. 'NONE',
  714. '-i',
  715. 'NONE',
  716. '-N',
  717. '--cmd',
  718. 'set shortmess+=I noswapfile belloff= noshowcmd noruler' .. extra,
  719. '--cmd',
  720. 'colorscheme vim',
  721. '--embed',
  722. }
  723. local screen_nvim = n.new_session(false, { args = nvim_argv, merge = false })
  724. set_session(screen_nvim)
  725. screen = Screen.new(53, 14, { rgb = true, ext_termcolors = termcolors or nil })
  726. end
  727. it('are dark per default', function()
  728. startup(false, false)
  729. screen:expect {
  730. condition = function()
  731. eq({
  732. rgb_bg = 0,
  733. rgb_fg = Screen.colors.White,
  734. rgb_sp = Screen.colors.Red,
  735. cterm_bg = 0,
  736. cterm_fg = 0,
  737. }, screen.default_colors)
  738. end,
  739. }
  740. end)
  741. it('can be set to light', function()
  742. startup(true, false)
  743. screen:expect {
  744. condition = function()
  745. eq({
  746. rgb_bg = Screen.colors.White,
  747. rgb_fg = 0,
  748. rgb_sp = Screen.colors.Red,
  749. cterm_bg = 0,
  750. cterm_fg = 0,
  751. }, screen.default_colors)
  752. end,
  753. }
  754. end)
  755. it('can be handled by external terminal', function()
  756. startup(false, true)
  757. screen:expect {
  758. condition = function()
  759. eq(
  760. { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 },
  761. screen.default_colors
  762. )
  763. end,
  764. }
  765. startup(true, true)
  766. screen:expect {
  767. condition = function()
  768. eq(
  769. { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 },
  770. screen.default_colors
  771. )
  772. end,
  773. }
  774. end)
  775. end)
  776. it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function()
  777. clear()
  778. local screen = Screen.new(100, 100)
  779. eq(100, api.nvim_get_option_value('lines', {}))
  780. eq(99, api.nvim_get_option_value('window', {}))
  781. eq(99, api.nvim_win_get_height(0))
  782. feed('1000o<Esc>')
  783. eq(903, fn.line('w0'))
  784. feed('<C-B>')
  785. eq(806, fn.line('w0'))
  786. feed('<C-B>')
  787. eq(709, fn.line('w0'))
  788. feed('<C-F>')
  789. eq(806, fn.line('w0'))
  790. feed('<C-F>')
  791. eq(903, fn.line('w0'))
  792. feed('G')
  793. screen:try_resize(50, 50)
  794. eq(50, api.nvim_get_option_value('lines', {}))
  795. eq(49, api.nvim_get_option_value('window', {}))
  796. eq(49, api.nvim_win_get_height(0))
  797. eq(953, fn.line('w0'))
  798. feed('<C-B>')
  799. eq(906, fn.line('w0'))
  800. feed('<C-B>')
  801. eq(859, fn.line('w0'))
  802. feed('<C-F>')
  803. eq(906, fn.line('w0'))
  804. feed('<C-F>')
  805. eq(953, fn.line('w0'))
  806. end)
  807. it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function()
  808. clear()
  809. local screen = Screen.new(30, 2)
  810. command('set showcmd redrawdebug=compositor')
  811. feed('d')
  812. screen:expect {
  813. grid = [[
  814. ^ |
  815. d |
  816. ]],
  817. }
  818. end)
  819. it("scrolling in narrow window doesn't draw over separator #29033", function()
  820. clear()
  821. local screen = Screen.new(60, 8)
  822. feed('100Oa<Esc>gg')
  823. exec([[
  824. set number nowrap
  825. vsplit
  826. set scrollbind
  827. wincmd l
  828. set scrollbind
  829. wincmd |
  830. ]])
  831. screen:expect([[
  832. {8: }│{8: 1 }^a |
  833. {8: }│{8: 2 }a |
  834. {8: }│{8: 3 }a |
  835. {8: }│{8: 4 }a |
  836. {8: }│{8: 5 }a |
  837. {8: }│{8: 6 }a |
  838. {2:< }{3:[No Name] [+] }|
  839. |
  840. ]])
  841. feed('<C-F>')
  842. screen:expect([[
  843. {8: }│{8: 5 }^a |
  844. {8: }│{8: 6 }a |
  845. {8: }│{8: 7 }a |
  846. {8: }│{8: 8 }a |
  847. {8: }│{8: 9 }a |
  848. {8: }│{8: 10 }a |
  849. {2:< }{3:[No Name] [+] }|
  850. |
  851. ]])
  852. end)