window_split_tab_spec.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local tt = require('test.functional.testterm')
  4. local assert_alive = n.assert_alive
  5. local clear = n.clear
  6. local feed = n.feed
  7. local feed_command = n.feed_command
  8. local command = n.command
  9. local eq = t.eq
  10. local eval = n.eval
  11. local api = n.api
  12. local sleep = vim.uv.sleep
  13. local retry = t.retry
  14. local is_os = t.is_os
  15. describe(':terminal', function()
  16. local screen
  17. before_each(function()
  18. clear()
  19. -- set the statusline to a constant value because of variables like pid
  20. -- and current directory and to improve visibility of splits
  21. api.nvim_set_option_value('statusline', '==========', {})
  22. screen = tt.setup_screen(3)
  23. command('highlight StatusLine NONE')
  24. command('highlight StatusLineNC NONE')
  25. command('highlight StatusLineTerm NONE')
  26. command('highlight StatusLineTermNC NONE')
  27. command('highlight VertSplit NONE')
  28. end)
  29. it('next to a closing window', function()
  30. command('split')
  31. command('terminal')
  32. command('vsplit foo')
  33. eq(3, eval("winnr('$')"))
  34. feed('ZQ') -- Close split, should not crash. #7538
  35. assert_alive()
  36. end)
  37. it('does not change size on WinEnter', function()
  38. feed('<c-\\><c-n>')
  39. feed('k')
  40. feed_command('2split')
  41. screen:expect([[
  42. ^tty ready |
  43. rows: 5, cols: 50 |
  44. ========== |
  45. tty ready |
  46. rows: 5, cols: 50 |
  47. |
  48. |*2
  49. ========== |
  50. :2split |
  51. ]])
  52. feed_command('wincmd p')
  53. screen:expect([[
  54. tty ready |
  55. rows: 5, cols: 50 |
  56. ========== |
  57. ^tty ready |
  58. rows: 5, cols: 50 |
  59. |
  60. |*2
  61. ========== |
  62. :wincmd p |
  63. ]])
  64. end)
  65. it('does not change size if updated when not visible in any window #19665', function()
  66. local channel = api.nvim_get_option_value('channel', {})
  67. command('enew')
  68. sleep(100)
  69. api.nvim_chan_send(channel, 'foo')
  70. sleep(100)
  71. command('bprevious')
  72. screen:expect([[
  73. tty ready |
  74. ^foo |
  75. |*8
  76. ]])
  77. end)
  78. it('forwards resize request to the program', function()
  79. feed([[<C-\><C-N>G]])
  80. local w1, h1 = screen._width - 3, screen._height - 2
  81. local w2, h2 = w1 - 6, h1 - 3
  82. if is_os('win') then
  83. -- win: SIGWINCH is unreliable, use a weaker test. #7506
  84. retry(3, 30000, function()
  85. screen:try_resize(w1, h1)
  86. screen:expect { any = 'rows: 7, cols: 47' }
  87. screen:try_resize(w2, h2)
  88. screen:expect { any = 'rows: 4, cols: 41' }
  89. end)
  90. return
  91. end
  92. screen:try_resize(w1, h1)
  93. screen:expect([[
  94. tty ready |
  95. rows: 7, cols: 47 |
  96. |
  97. |*3
  98. ^ |
  99. |
  100. ]])
  101. screen:try_resize(w2, h2)
  102. screen:expect([[
  103. tty ready |
  104. rows: 7, cols: 47 |
  105. rows: 4, cols: 41 |
  106. ^ |
  107. |
  108. ]])
  109. end)
  110. it('stays in terminal mode with <Cmd>wincmd', function()
  111. command('terminal')
  112. command('split')
  113. command('terminal')
  114. feed('a<Cmd>wincmd j<CR>')
  115. eq(2, eval('winnr()'))
  116. eq('t', eval('mode(1)'))
  117. end)
  118. end)