tabnewentered_spec.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local clear = n.clear
  4. local command = n.command
  5. local dedent = t.dedent
  6. local eval = n.eval
  7. local eq = t.eq
  8. local feed = n.feed
  9. local api = n.api
  10. local exec_capture = n.exec_capture
  11. describe('TabNewEntered', function()
  12. describe('au TabNewEntered', function()
  13. describe('with * as <afile>', function()
  14. it('matches when entering any new tab', function()
  15. clear()
  16. command('au! TabNewEntered * echom "tabnewentered:".tabpagenr().":".bufnr("")')
  17. eq('tabnewentered:2:2', api.nvim_exec('tabnew', true))
  18. eq('tabnewentered:3:3', api.nvim_exec('tabnew test.x2', true))
  19. end)
  20. end)
  21. describe('with FILE as <afile>', function()
  22. it('matches when opening a new tab for FILE', function()
  23. clear()
  24. command('au! TabNewEntered Xtest-tabnewentered echom "tabnewentered:match"')
  25. eq('tabnewentered:match', api.nvim_exec('tabnew Xtest-tabnewentered', true))
  26. end)
  27. end)
  28. describe('with CTRL-W T', function()
  29. it('works when opening a new tab with CTRL-W T', function()
  30. clear()
  31. command('au! TabNewEntered * echom "entered"')
  32. command('tabnew test.x2')
  33. command('split')
  34. eq('entered', api.nvim_exec('execute "normal \\<C-W>T"', true))
  35. end)
  36. end)
  37. describe('with tab split #4334', function()
  38. it('works when create a tab by using tab split command', function()
  39. clear()
  40. command('au! TabNewEntered * let b:entered = "entered"')
  41. command('tab split')
  42. eq('entered', api.nvim_exec('echo b:entered', true))
  43. end)
  44. end)
  45. end)
  46. end)
  47. describe('TabEnter', function()
  48. before_each(clear)
  49. it('has correct previous tab when entering any new tab', function()
  50. command('augroup TEMP')
  51. command('au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
  52. command('augroup END')
  53. eq('tabenter:2:1', api.nvim_exec('tabnew', true))
  54. eq('tabenter:3:2', api.nvim_exec('tabnew test.x2', true))
  55. command('augroup! TEMP')
  56. end)
  57. it('has correct previous tab when entering any preexisting tab', function()
  58. command('tabnew')
  59. command('tabnew')
  60. command('augroup TEMP')
  61. command('au! TabEnter * echom "tabenter:".tabpagenr().":".tabpagenr(\'#\')')
  62. command('augroup END')
  63. eq('tabenter:1:3', api.nvim_exec('tabnext', true))
  64. eq('tabenter:2:1', api.nvim_exec('tabnext', true))
  65. command('augroup! TEMP')
  66. end)
  67. end)
  68. describe('tabpage/previous', function()
  69. before_each(clear)
  70. local function switches_to_previous_after_new_tab_creation_at_end(characters)
  71. return function()
  72. -- Add three tabs for a total of four
  73. command('tabnew')
  74. command('tabnew')
  75. command('tabnew')
  76. -- The previous tab is now the third.
  77. eq(3, eval("tabpagenr('#')"))
  78. -- Switch to the previous (third) tab
  79. feed(characters)
  80. eq(
  81. dedent([=[
  82. Tab page 1
  83. [No Name]
  84. Tab page 2
  85. [No Name]
  86. Tab page 3
  87. > [No Name]
  88. Tab page 4
  89. # [No Name]]=]),
  90. exec_capture('tabs')
  91. )
  92. -- The previous tab is now the fourth.
  93. eq(4, eval("tabpagenr('#')"))
  94. end
  95. end
  96. it(
  97. 'switches to previous via g<Tab> after new tab creation at end',
  98. switches_to_previous_after_new_tab_creation_at_end('g<Tab>')
  99. )
  100. it(
  101. 'switches to previous via <C-W>g<Tab>. after new tab creation at end',
  102. switches_to_previous_after_new_tab_creation_at_end('<C-W>g<Tab>')
  103. )
  104. it(
  105. 'switches to previous via <C-Tab>. after new tab creation at end',
  106. switches_to_previous_after_new_tab_creation_at_end('<C-Tab>')
  107. )
  108. it(
  109. 'switches to previous via :tabn #<CR>. after new tab creation at end',
  110. switches_to_previous_after_new_tab_creation_at_end(':tabn #<CR>')
  111. )
  112. local function switches_to_previous_after_new_tab_creation_in_middle(characters)
  113. return function()
  114. -- Add three tabs for a total of four
  115. command('tabnew')
  116. command('tabnew')
  117. command('tabnew')
  118. -- Switch to the second tab
  119. command('tabnext 2')
  120. -- Add a new tab after the second tab
  121. command('tabnew')
  122. -- The previous tab is now the second.
  123. eq(2, eval("tabpagenr('#')"))
  124. -- Switch to the previous (second) tab
  125. feed(characters)
  126. eq(
  127. dedent([=[
  128. Tab page 1
  129. [No Name]
  130. Tab page 2
  131. > [No Name]
  132. Tab page 3
  133. # [No Name]
  134. Tab page 4
  135. [No Name]
  136. Tab page 5
  137. [No Name]]=]),
  138. exec_capture('tabs')
  139. )
  140. -- The previous tab is now the third.
  141. eq(3, eval("tabpagenr('#')"))
  142. end
  143. end
  144. it(
  145. 'switches to previous via g<Tab> after new tab creation in middle',
  146. switches_to_previous_after_new_tab_creation_in_middle('g<Tab>')
  147. )
  148. it(
  149. 'switches to previous via <C-W>g<Tab> after new tab creation in middle',
  150. switches_to_previous_after_new_tab_creation_in_middle('<C-W>g<Tab>')
  151. )
  152. it(
  153. 'switches to previous via <C-Tab> after new tab creation in middle',
  154. switches_to_previous_after_new_tab_creation_in_middle('<C-Tab>')
  155. )
  156. it(
  157. 'switches to previous via :tabn #<CR> after new tab creation in middle',
  158. switches_to_previous_after_new_tab_creation_in_middle(':tabn #<CR>')
  159. )
  160. local function switches_to_previous_after_switching_to_next_tab(characters)
  161. return function()
  162. -- Add three tabs for a total of four
  163. command('tabnew')
  164. command('tabnew')
  165. command('tabnew')
  166. -- Switch to the next (first) tab
  167. command('tabnext')
  168. -- The previous tab is now the fourth.
  169. eq(4, eval("tabpagenr('#')"))
  170. -- Switch to the previous (fourth) tab
  171. feed(characters)
  172. eq(
  173. dedent([=[
  174. Tab page 1
  175. # [No Name]
  176. Tab page 2
  177. [No Name]
  178. Tab page 3
  179. [No Name]
  180. Tab page 4
  181. > [No Name]]=]),
  182. exec_capture('tabs')
  183. )
  184. -- The previous tab is now the first.
  185. eq(1, eval("tabpagenr('#')"))
  186. end
  187. end
  188. it(
  189. 'switches to previous via g<Tab> after switching to next tab',
  190. switches_to_previous_after_switching_to_next_tab('g<Tab>')
  191. )
  192. it(
  193. 'switches to previous via <C-W>g<Tab> after switching to next tab',
  194. switches_to_previous_after_switching_to_next_tab('<C-W>g<Tab>')
  195. )
  196. it(
  197. 'switches to previous via <C-Tab> after switching to next tab',
  198. switches_to_previous_after_switching_to_next_tab('<C-Tab>')
  199. )
  200. it(
  201. 'switches to previous via :tabn #<CR> after switching to next tab',
  202. switches_to_previous_after_switching_to_next_tab(':tabn #<CR>')
  203. )
  204. local function switches_to_previous_after_switching_to_last_tab(characters)
  205. return function()
  206. -- Add three tabs for a total of four
  207. command('tabnew')
  208. command('tabnew')
  209. command('tabnew')
  210. -- Switch to the next (first) tab
  211. command('tabnext')
  212. -- Switch to the last (fourth) tab.
  213. command('tablast')
  214. -- The previous tab is now the second.
  215. eq(1, eval("tabpagenr('#')"))
  216. -- Switch to the previous (second) tab
  217. feed(characters)
  218. eq(
  219. dedent([=[
  220. Tab page 1
  221. > [No Name]
  222. Tab page 2
  223. [No Name]
  224. Tab page 3
  225. [No Name]
  226. Tab page 4
  227. # [No Name]]=]),
  228. exec_capture('tabs')
  229. )
  230. -- The previous tab is now the fourth.
  231. eq(4, eval("tabpagenr('#')"))
  232. end
  233. end
  234. it(
  235. 'switches to previous after switching to last tab',
  236. switches_to_previous_after_switching_to_last_tab('g<Tab>')
  237. )
  238. it(
  239. 'switches to previous after switching to last tab',
  240. switches_to_previous_after_switching_to_last_tab('<C-W>g<Tab>')
  241. )
  242. it(
  243. 'switches to previous after switching to last tab',
  244. switches_to_previous_after_switching_to_last_tab('<C-Tab>')
  245. )
  246. it(
  247. 'switches to previous after switching to last tab',
  248. switches_to_previous_after_switching_to_last_tab(':tabn #<CR>')
  249. )
  250. local function switches_to_previous_after_switching_to_previous_tab(characters)
  251. return function()
  252. -- Add three tabs for a total of four
  253. command('tabnew')
  254. command('tabnew')
  255. command('tabnew')
  256. -- Switch to the previous (third) tab
  257. command('tabprevious')
  258. -- The previous tab is now the fourth.
  259. eq(4, eval("tabpagenr('#')"))
  260. -- Switch to the previous (fourth) tab
  261. feed(characters)
  262. eq(
  263. dedent([=[
  264. Tab page 1
  265. [No Name]
  266. Tab page 2
  267. [No Name]
  268. Tab page 3
  269. # [No Name]
  270. Tab page 4
  271. > [No Name]]=]),
  272. exec_capture('tabs')
  273. )
  274. -- The previous tab is now the third.
  275. eq(3, eval("tabpagenr('#')"))
  276. end
  277. end
  278. it(
  279. 'switches to previous via g<Tab> after switching to previous tab',
  280. switches_to_previous_after_switching_to_previous_tab('g<Tab>')
  281. )
  282. it(
  283. 'switches to previous via <C-W>g<Tab> after switching to previous tab',
  284. switches_to_previous_after_switching_to_previous_tab('<C-W>g<Tab>')
  285. )
  286. it(
  287. 'switches to previous via <C-Tab> after switching to previous tab',
  288. switches_to_previous_after_switching_to_previous_tab('<C-Tab>')
  289. )
  290. it(
  291. 'switches to previous via :tabn #<CR> after switching to previous tab',
  292. switches_to_previous_after_switching_to_previous_tab(':tabn #<CR>')
  293. )
  294. local function switches_to_previous_after_switching_to_first_tab(characters)
  295. return function()
  296. -- Add three tabs for a total of four
  297. command('tabnew')
  298. command('tabnew')
  299. command('tabnew')
  300. -- Switch to the previous (third) tab
  301. command('tabprevious')
  302. -- Switch to the first tab
  303. command('tabfirst')
  304. -- The previous tab is now the third.
  305. eq(3, eval("tabpagenr('#')"))
  306. -- Switch to the previous (third) tab
  307. feed(characters)
  308. eq(
  309. dedent([=[
  310. Tab page 1
  311. # [No Name]
  312. Tab page 2
  313. [No Name]
  314. Tab page 3
  315. > [No Name]
  316. Tab page 4
  317. [No Name]]=]),
  318. exec_capture('tabs')
  319. )
  320. -- The previous tab is now the first.
  321. eq(1, eval("tabpagenr('#')"))
  322. end
  323. end
  324. it(
  325. 'switches to previous via g<Tab> after switching to first tab',
  326. switches_to_previous_after_switching_to_first_tab('g<Tab>')
  327. )
  328. it(
  329. 'switches to previous via <C-W>g<Tab> after switching to first tab',
  330. switches_to_previous_after_switching_to_first_tab('<C-W>g<Tab>')
  331. )
  332. it(
  333. 'switches to previous via <C-Tab> after switching to first tab',
  334. switches_to_previous_after_switching_to_first_tab('<C-Tab>')
  335. )
  336. it(
  337. 'switches to previous via :tabn #<CR> after switching to first tab',
  338. switches_to_previous_after_switching_to_first_tab(':tabn #<CR>')
  339. )
  340. local function switches_to_previous_after_numbered_tab_switch(characters)
  341. return function()
  342. -- Add three tabs for a total of four
  343. command('tabnew')
  344. command('tabnew')
  345. command('tabnew')
  346. -- Switch to the second tab
  347. command('tabnext 2')
  348. -- The previous tab is now the fourth.
  349. eq(4, eval("tabpagenr('#')"))
  350. -- Switch to the previous (fourth) tab
  351. feed(characters)
  352. eq(
  353. dedent([=[
  354. Tab page 1
  355. [No Name]
  356. Tab page 2
  357. # [No Name]
  358. Tab page 3
  359. [No Name]
  360. Tab page 4
  361. > [No Name]]=]),
  362. exec_capture('tabs')
  363. )
  364. -- The previous tab is now the second.
  365. eq(2, eval("tabpagenr('#')"))
  366. end
  367. end
  368. it(
  369. 'switches to previous via g<Tab> after numbered tab switch',
  370. switches_to_previous_after_numbered_tab_switch('g<Tab>')
  371. )
  372. it(
  373. 'switches to previous via <C-W>g<Tab> after numbered tab switch',
  374. switches_to_previous_after_numbered_tab_switch('<C-W>g<Tab>')
  375. )
  376. it(
  377. 'switches to previous via <C-Tab> after numbered tab switch',
  378. switches_to_previous_after_numbered_tab_switch('<C-Tab>')
  379. )
  380. it(
  381. 'switches to previous via :tabn #<CR> after numbered tab switch',
  382. switches_to_previous_after_numbered_tab_switch(':tabn #<CR>')
  383. )
  384. local function switches_to_previous_after_switching_to_previous(characters1, characters2)
  385. return function()
  386. -- Add three tabs for a total of four
  387. command('tabnew')
  388. command('tabnew')
  389. command('tabnew')
  390. -- Switch to the second tab
  391. command('tabnext 2')
  392. -- Switch to the previous (fourth) tab
  393. feed(characters1)
  394. -- The previous tab is now the second.
  395. eq(2, eval("tabpagenr('#')"))
  396. -- Switch to the previous (second) tab
  397. feed(characters2)
  398. eq(
  399. dedent([=[
  400. Tab page 1
  401. [No Name]
  402. Tab page 2
  403. > [No Name]
  404. Tab page 3
  405. [No Name]
  406. Tab page 4
  407. # [No Name]]=]),
  408. exec_capture('tabs')
  409. )
  410. -- The previous tab is now the fourth.
  411. eq(4, eval("tabpagenr('#')"))
  412. end
  413. end
  414. it(
  415. 'switches to previous via g<Tab> after switching to previous via g<Tab>',
  416. switches_to_previous_after_switching_to_previous('g<Tab>', 'g<Tab>')
  417. )
  418. it(
  419. 'switches to previous via <C-W>g<Tab> after switching to previous via g<Tab>',
  420. switches_to_previous_after_switching_to_previous('g<Tab>', '<C-W>g<Tab>')
  421. )
  422. it(
  423. 'switches to previous via <C-Tab> after switching to previous via g<Tab>',
  424. switches_to_previous_after_switching_to_previous('g<Tab>', '<C-Tab>')
  425. )
  426. it(
  427. 'switches to previous via :tabn #<CR> after switching to previous via g<Tab>',
  428. switches_to_previous_after_switching_to_previous('g<Tab>', ':tabn #<CR>')
  429. )
  430. it(
  431. 'switches to previous via g<Tab> after switching to previous via <C-W>g<Tab>',
  432. switches_to_previous_after_switching_to_previous('<C-W>g<Tab>', 'g<Tab>')
  433. )
  434. it(
  435. 'switches to previous via <C-W>g<Tab> after switching to previous via <C-W>g<Tab>',
  436. switches_to_previous_after_switching_to_previous('<C-W>g<Tab>', '<C-W>g<Tab>')
  437. )
  438. it(
  439. 'switches to previous via <C-Tab> after switching to previous via <C-W>g<Tab>',
  440. switches_to_previous_after_switching_to_previous('<C-W>g<Tab>', '<C-Tab>')
  441. )
  442. it(
  443. 'switches to previous via :tabn #<CR> after switching to previous via <C-W>g<Tab>',
  444. switches_to_previous_after_switching_to_previous('<C-W>g<Tab>', ':tabn #<CR>')
  445. )
  446. it(
  447. 'switches to previous via g<Tab> after switching to previous via <C-Tab>',
  448. switches_to_previous_after_switching_to_previous('<C-Tab>', 'g<Tab>')
  449. )
  450. it(
  451. 'switches to previous via <C-W>g<Tab> after switching to previous via <C-Tab>',
  452. switches_to_previous_after_switching_to_previous('<C-Tab>', '<C-W>g<Tab>')
  453. )
  454. it(
  455. 'switches to previous via <C-Tab> after switching to previous via <C-Tab>',
  456. switches_to_previous_after_switching_to_previous('<C-Tab>', '<C-Tab>')
  457. )
  458. it(
  459. 'switches to previous via :tabn #<CR> after switching to previous via <C-Tab>',
  460. switches_to_previous_after_switching_to_previous('<C-Tab>', ':tabn #<CR>')
  461. )
  462. it(
  463. 'switches to previous via g<Tab> after switching to previous via :tabn #<CR>',
  464. switches_to_previous_after_switching_to_previous(':tabn #<CR>', 'g<Tab>')
  465. )
  466. it(
  467. 'switches to previous via <C-W>g<Tab> after switching to previous via :tabn #<CR>',
  468. switches_to_previous_after_switching_to_previous(':tabn #<CR>', '<C-W>g<Tab>')
  469. )
  470. it(
  471. 'switches to previous via <C-Tab> after switching to previous via <C-Tab>',
  472. switches_to_previous_after_switching_to_previous(':tabn #<CR>', '<C-Tab>')
  473. )
  474. it(
  475. 'switches to previous via :tabn #<CR> after switching to previous via :tabn #<CR>',
  476. switches_to_previous_after_switching_to_previous(':tabn #<CR>', ':tabn #<CR>')
  477. )
  478. local function does_not_switch_to_previous_after_closing_current_tab(characters)
  479. return function()
  480. -- Add three tabs for a total of four
  481. command('tabnew')
  482. command('tabnew')
  483. command('tabnew')
  484. -- Close the current (fourth tab)
  485. command('wincmd c')
  486. -- The previous tab is now the "zeroth" -- there isn't one.
  487. eq(0, eval("tabpagenr('#')"))
  488. -- At this point, switching to the "previous" (i.e. fourth) tab would mean
  489. -- switching to either a dangling or a null pointer.
  490. feed(characters)
  491. eq(
  492. dedent([=[
  493. Tab page 1
  494. [No Name]
  495. Tab page 2
  496. [No Name]
  497. Tab page 3
  498. > [No Name]]=]),
  499. exec_capture('tabs')
  500. )
  501. -- The previous tab is now the "zero".
  502. eq(0, eval("tabpagenr('#')"))
  503. end
  504. end
  505. it(
  506. 'does not switch to previous via g<Tab> after closing current tab',
  507. does_not_switch_to_previous_after_closing_current_tab('g<Tab>')
  508. )
  509. it(
  510. 'does not switch to previous via <C-W>g<Tab> after closing current tab',
  511. does_not_switch_to_previous_after_closing_current_tab('<C-W>g<Tab>')
  512. )
  513. it(
  514. 'does not switch to previous via <C-Tab> after closing current tab',
  515. does_not_switch_to_previous_after_closing_current_tab('<C-Tab>')
  516. )
  517. it(
  518. 'does not switch to previous via :tabn #<CR> after closing current tab',
  519. does_not_switch_to_previous_after_closing_current_tab(':tabn #<CR>')
  520. )
  521. local function does_not_switch_to_previous_after_entering_operator_pending(characters)
  522. return function()
  523. -- Add three tabs for a total of four
  524. command('tabnew')
  525. command('tabnew')
  526. command('tabnew')
  527. -- The previous tab is now the third.
  528. eq(3, eval("tabpagenr('#')"))
  529. -- Enter operator pending mode.
  530. feed('d')
  531. eq('no', eval('mode(1)'))
  532. -- At this point switching to the previous tab should have no effect
  533. -- other than leaving operator pending mode.
  534. feed(characters)
  535. -- Attempting to switch tabs returns us to normal mode.
  536. eq('n', eval('mode()'))
  537. -- The current tab is still the fourth.
  538. eq(4, eval('tabpagenr()'))
  539. -- The previous tab is still the third.
  540. eq(3, eval("tabpagenr('#')"))
  541. end
  542. end
  543. it(
  544. 'does not switch to previous via g<Tab> after entering operator pending',
  545. does_not_switch_to_previous_after_entering_operator_pending('g<Tab>')
  546. )
  547. -- NOTE: When in operator pending mode, attempting to switch to previous has
  548. -- the following effect:
  549. -- - Ctrl-W exits operator pending mode
  550. -- - g<Tab> switches to the previous tab
  551. -- In other words, the effect of "<C-W>g<Tab>" is to switch to the
  552. -- previous tab even from operator pending mode, but only thanks to the
  553. -- fact that the suffix after "<C-W>" in "<C-W>g<Tab>" just happens to
  554. -- be the same as the normal mode command to switch to the previous tab.
  555. -- it('does not switch to previous via <C-W>g<Tab> after entering operator pending',
  556. -- does_not_switch_to_previous_after_entering_operator_pending('<C-W>g<Tab>'))
  557. it(
  558. 'does not switch to previous via <C-Tab> after entering operator pending',
  559. does_not_switch_to_previous_after_entering_operator_pending('<C-Tab>')
  560. )
  561. -- NOTE: When in operator pending mode, pressing : leaves operator pending
  562. -- mode and enters command mode, so :tabn #<CR> does in fact switch
  563. -- tabs.
  564. -- it('does not switch to previous via :tabn #<CR> after entering operator pending',
  565. -- does_not_switch_to_previous_after_entering_operator_pending(':tabn #<CR>'))
  566. local function cmdline_win_prevents_tab_switch(characters, completion_visible)
  567. return function()
  568. -- Add three tabs for a total of four
  569. command('tabnew')
  570. command('tabnew')
  571. command('tabnew')
  572. -- The previous tab is now the third.
  573. eq(3, eval("tabpagenr('#')"))
  574. -- Edit : command line in command-line window
  575. feed('q:')
  576. local cmdline_win_id = eval('win_getid()')
  577. -- At this point switching to the previous tab should have no effect.
  578. feed(characters)
  579. -- Attempting to switch tabs maintains the current window.
  580. eq(cmdline_win_id, eval('win_getid()'))
  581. eq(completion_visible, eval('complete_info().pum_visible'))
  582. -- The current tab is still the fourth.
  583. eq(4, eval('tabpagenr()'))
  584. -- The previous tab is still the third.
  585. eq(3, eval("tabpagenr('#')"))
  586. end
  587. end
  588. it('cmdline-win prevents tab switch via g<Tab>', cmdline_win_prevents_tab_switch('g<Tab>', 0))
  589. it(
  590. 'cmdline-win prevents tab switch via <C-W>g<Tab>',
  591. cmdline_win_prevents_tab_switch('<C-W>g<Tab>', 1)
  592. )
  593. it('cmdline-win prevents tab switch via <C-Tab>', cmdline_win_prevents_tab_switch('<C-Tab>', 0))
  594. it(
  595. 'cmdline-win prevents tab switch via :tabn #<CR>',
  596. cmdline_win_prevents_tab_switch(':tabn #<CR>', 0)
  597. )
  598. it(':tabs indicates correct prevtab curwin', function()
  599. -- Add three tabs for a total of four
  600. command('tabnew')
  601. command('tabnew')
  602. command('split')
  603. command('vsplit')
  604. feed('<C-w>p')
  605. command('tabnew')
  606. -- The previous tab is now the three.
  607. eq(3, eval("tabpagenr('#')"))
  608. eq(
  609. dedent([=[
  610. Tab page 1
  611. [No Name]
  612. Tab page 2
  613. [No Name]
  614. Tab page 3
  615. [No Name]
  616. # [No Name]
  617. [No Name]
  618. Tab page 4
  619. > [No Name]]=]),
  620. exec_capture('tabs')
  621. )
  622. end)
  623. end)