mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	test: Add more functional test to cover new code
- emulate gui_running and terminal colors - scrolling/clearing regions - mouse wheel scrolling - setting icon/title - :stop/:suspend - screen resize
This commit is contained in:
		@@ -1,7 +1,30 @@
 | 
			
		||||
local helpers = require('test.functional.helpers')
 | 
			
		||||
local Screen = require('test.functional.ui.screen')
 | 
			
		||||
local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
 | 
			
		||||
local execute = helpers.execute
 | 
			
		||||
local execute, request, eq = helpers.execute, helpers.request, helpers.eq
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
describe('color scheme compatibility', function()
 | 
			
		||||
  before_each(function()
 | 
			
		||||
    clear()
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('t_Co is set to 256 by default', function()
 | 
			
		||||
    eq('256', request('vim_eval', '&t_Co'))
 | 
			
		||||
    request('vim_set_option', 't_Co', '88')
 | 
			
		||||
    eq('88', request('vim_eval', '&t_Co'))
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('emulates gui_running when a rgb UI is attached', function()
 | 
			
		||||
    eq(0, request('vim_eval', 'has("gui_running")'))
 | 
			
		||||
    local screen = Screen.new()
 | 
			
		||||
    screen:attach()
 | 
			
		||||
    eq(1, request('vim_eval', 'has("gui_running")'))
 | 
			
		||||
    screen:detach()
 | 
			
		||||
    eq(0, request('vim_eval', 'has("gui_running")'))
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
describe('Default highlight groups', function()
 | 
			
		||||
  -- Test the default attributes for highlight groups shown by the :highlight
 | 
			
		||||
@@ -24,7 +47,6 @@ describe('Default highlight groups', function()
 | 
			
		||||
  after_each(function()
 | 
			
		||||
    screen:detach()
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('window status bar', function()
 | 
			
		||||
    screen:set_default_attr_ids({
 | 
			
		||||
      [1] = {reverse = true, bold = true},  -- StatusLine
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
local helpers = require('test.functional.helpers')
 | 
			
		||||
local Screen = require('test.functional.ui.screen')
 | 
			
		||||
local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
 | 
			
		||||
local insert, execute = helpers.insert, helpers.execute
 | 
			
		||||
 | 
			
		||||
describe('Mouse input', function()
 | 
			
		||||
  local screen, hlgroup_colors
 | 
			
		||||
@@ -154,4 +155,87 @@ describe('Mouse input', function()
 | 
			
		||||
    ]])
 | 
			
		||||
    feed('<cr>')
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  it('mouse whell will target the hovered window', function()
 | 
			
		||||
    feed('ggdG')
 | 
			
		||||
    insert([[
 | 
			
		||||
    Inserting
 | 
			
		||||
    text
 | 
			
		||||
    with
 | 
			
		||||
    many
 | 
			
		||||
    lines
 | 
			
		||||
    to
 | 
			
		||||
    test
 | 
			
		||||
    mouse scrolling
 | 
			
		||||
    ]])
 | 
			
		||||
    screen:try_resize(53, 14)
 | 
			
		||||
    execute('sp', 'vsp')
 | 
			
		||||
    screen:expect([[
 | 
			
		||||
      lines                     |lines                     |
 | 
			
		||||
      to                        |to                        |
 | 
			
		||||
      test                      |test                      |
 | 
			
		||||
      mouse scrolling           |mouse scrolling           |
 | 
			
		||||
      ^                         |                          |
 | 
			
		||||
      ~                         |~                         |
 | 
			
		||||
      [No Name] [+]              [No Name] [+]             |
 | 
			
		||||
      to                                                   |
 | 
			
		||||
      test                                                 |
 | 
			
		||||
      mouse scrolling                                      |
 | 
			
		||||
                                                           |
 | 
			
		||||
      ~                                                    |
 | 
			
		||||
      [No Name] [+]                                        |
 | 
			
		||||
      :vsp                                                 |
 | 
			
		||||
    ]])
 | 
			
		||||
    feed('<MouseUp><0,0>')
 | 
			
		||||
    screen:expect([[
 | 
			
		||||
      mouse scrolling           |lines                     |
 | 
			
		||||
      ^                         |to                        |
 | 
			
		||||
      ~                         |test                      |
 | 
			
		||||
      ~                         |mouse scrolling           |
 | 
			
		||||
      ~                         |                          |
 | 
			
		||||
      ~                         |~                         |
 | 
			
		||||
      [No Name] [+]              [No Name] [+]             |
 | 
			
		||||
      to                                                   |
 | 
			
		||||
      test                                                 |
 | 
			
		||||
      mouse scrolling                                      |
 | 
			
		||||
                                                           |
 | 
			
		||||
      ~                                                    |
 | 
			
		||||
      [No Name] [+]                                        |
 | 
			
		||||
                                                           |
 | 
			
		||||
    ]])
 | 
			
		||||
    feed('<MouseDown><27,0>')
 | 
			
		||||
    screen:expect([[
 | 
			
		||||
      mouse scrolling           |text                      |
 | 
			
		||||
      ^                         |with                      |
 | 
			
		||||
      ~                         |many                      |
 | 
			
		||||
      ~                         |lines                     |
 | 
			
		||||
      ~                         |to                        |
 | 
			
		||||
      ~                         |test                      |
 | 
			
		||||
      [No Name] [+]              [No Name] [+]             |
 | 
			
		||||
      to                                                   |
 | 
			
		||||
      test                                                 |
 | 
			
		||||
      mouse scrolling                                      |
 | 
			
		||||
                                                           |
 | 
			
		||||
      ~                                                    |
 | 
			
		||||
      [No Name] [+]                                        |
 | 
			
		||||
                                                           |
 | 
			
		||||
    ]])
 | 
			
		||||
    feed('<MouseDown><27,7><MouseDown>')
 | 
			
		||||
    screen:expect([[
 | 
			
		||||
      mouse scrolling           |text                      |
 | 
			
		||||
      ^                         |with                      |
 | 
			
		||||
      ~                         |many                      |
 | 
			
		||||
      ~                         |lines                     |
 | 
			
		||||
      ~                         |to                        |
 | 
			
		||||
      ~                         |test                      |
 | 
			
		||||
      [No Name] [+]              [No Name] [+]             |
 | 
			
		||||
      Inserting                                            |
 | 
			
		||||
      text                                                 |
 | 
			
		||||
      with                                                 |
 | 
			
		||||
      many                                                 |
 | 
			
		||||
      lines                                                |
 | 
			
		||||
      [No Name] [+]                                        |
 | 
			
		||||
                                                           |
 | 
			
		||||
    ]])
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 
 | 
			
		||||
@@ -105,26 +105,22 @@ function Screen.new(width, height)
 | 
			
		||||
  if not height then
 | 
			
		||||
    height = 14
 | 
			
		||||
  end
 | 
			
		||||
  return setmetatable({
 | 
			
		||||
  local self = setmetatable({
 | 
			
		||||
    title = '',
 | 
			
		||||
    icon = '',
 | 
			
		||||
    bell = false,
 | 
			
		||||
    visual_bell = false,
 | 
			
		||||
    suspended = false,
 | 
			
		||||
    _default_attr_ids = nil,
 | 
			
		||||
    _width = width,
 | 
			
		||||
    _height = height,
 | 
			
		||||
    _rows = new_cell_grid(width, height),
 | 
			
		||||
    _mode = 'normal',
 | 
			
		||||
    _mouse_enabled = true,
 | 
			
		||||
    _bell = false,
 | 
			
		||||
    _visual_bell = false,
 | 
			
		||||
    _suspended = true,
 | 
			
		||||
    _title = nil,
 | 
			
		||||
    _icon = nil,
 | 
			
		||||
    _attrs = {},
 | 
			
		||||
    _cursor = {
 | 
			
		||||
      enabled = true, row = 1, col = 1
 | 
			
		||||
    },
 | 
			
		||||
    _scroll_region = {
 | 
			
		||||
      top = 1, bot = height, left = 1, right = width
 | 
			
		||||
    }
 | 
			
		||||
  }, Screen)
 | 
			
		||||
  self:_handle_resize(width, height)
 | 
			
		||||
  return self
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:set_default_attr_ids(attr_ids)
 | 
			
		||||
@@ -133,12 +129,14 @@ end
 | 
			
		||||
 | 
			
		||||
function Screen:attach()
 | 
			
		||||
  request('ui_attach', self._width, self._height, true)
 | 
			
		||||
  self._suspended = false
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:detach()
 | 
			
		||||
  request('ui_detach')
 | 
			
		||||
  self._suspended = true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:try_resize(columns, rows)
 | 
			
		||||
  request('ui_try_resize', columns, rows)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:expect(expected, attr_ids)
 | 
			
		||||
@@ -151,7 +149,7 @@ function Screen:expect(expected, attr_ids)
 | 
			
		||||
    table.insert(expected_rows, row)
 | 
			
		||||
  end
 | 
			
		||||
  local ids = attr_ids or self._default_attr_ids
 | 
			
		||||
  self:_wait(function()
 | 
			
		||||
  self:wait(function()
 | 
			
		||||
    for i = 1, self._height do
 | 
			
		||||
      local expected_row = expected_rows[i]
 | 
			
		||||
      local actual_row = self:_row_repr(self._rows[i], ids)
 | 
			
		||||
@@ -163,7 +161,7 @@ function Screen:expect(expected, attr_ids)
 | 
			
		||||
  end)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_wait(check, timeout)
 | 
			
		||||
function Screen:wait(check, timeout)
 | 
			
		||||
  local err, checked = false
 | 
			
		||||
  local function notification_cb(method, args)
 | 
			
		||||
    assert(method == 'redraw')
 | 
			
		||||
@@ -198,7 +196,20 @@ function Screen:_redraw(updates)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_resize(width, height)
 | 
			
		||||
  self._rows = new_cell_grid(width, height)
 | 
			
		||||
  local rows = {}
 | 
			
		||||
  for i = 1, height do
 | 
			
		||||
    local cols = {}
 | 
			
		||||
    for j = 1, width do
 | 
			
		||||
      table.insert(cols, {text = ' ', attrs = {}})
 | 
			
		||||
    end
 | 
			
		||||
    table.insert(rows, cols)
 | 
			
		||||
  end
 | 
			
		||||
  self._rows = rows
 | 
			
		||||
  self._width = width
 | 
			
		||||
  self._height = height
 | 
			
		||||
  self._scroll_region = {
 | 
			
		||||
    top = 1, bot = height, left = 1, right = width
 | 
			
		||||
  }
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_clear()
 | 
			
		||||
@@ -268,11 +279,14 @@ function Screen:_handle_scroll(count)
 | 
			
		||||
  for i = start, stop, step do
 | 
			
		||||
    local target = self._rows[i]
 | 
			
		||||
    local source = self._rows[i + count]
 | 
			
		||||
    self:_copy_row_section(target, source, left, right)
 | 
			
		||||
    for j = left, right do
 | 
			
		||||
      target[j].text = source[j].text
 | 
			
		||||
      target[j].attrs = source[j].attrs
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  -- clear invalid rows
 | 
			
		||||
  for i = stop + 1, stop + count, step do
 | 
			
		||||
  for i = stop + step, stop + count, step do
 | 
			
		||||
    self:_clear_row_section(i, left, right)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
@@ -289,11 +303,11 @@ function Screen:_handle_put(str)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_bell()
 | 
			
		||||
  self._bell = true
 | 
			
		||||
  self.bell = true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_visual_bell()
 | 
			
		||||
  self._visual_bell = true
 | 
			
		||||
  self.visual_bell = true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_update_fg(fg)
 | 
			
		||||
@@ -305,15 +319,15 @@ function Screen:_handle_update_bg(bg)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_suspend()
 | 
			
		||||
  self._suspended = true
 | 
			
		||||
  self.suspended = true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_set_title(title)
 | 
			
		||||
  self._title = title
 | 
			
		||||
  self.title = title
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_handle_set_icon(icon)
 | 
			
		||||
  self._icon = icon
 | 
			
		||||
  self.icon = icon
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_clear_block(top, lines, left, columns)
 | 
			
		||||
@@ -330,13 +344,6 @@ function Screen:_clear_row_section(rownum, startcol, stopcol)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_copy_row_section(target, source, startcol, stopcol)
 | 
			
		||||
  for i = startcol, stopcol do
 | 
			
		||||
    target[i].text = source[i].text
 | 
			
		||||
    target[i].attrs = source[i].attrs
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function Screen:_row_repr(row, attr_ids)
 | 
			
		||||
  local rv = {}
 | 
			
		||||
  local current_attr_id
 | 
			
		||||
@@ -387,18 +394,6 @@ function backward_find_meaningful(tbl, from)
 | 
			
		||||
  return from
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function new_cell_grid(width, height)
 | 
			
		||||
  local rows = {}
 | 
			
		||||
  for i = 1, height do
 | 
			
		||||
    local cols = {}
 | 
			
		||||
    for j = 1, width do
 | 
			
		||||
      table.insert(cols, {text = ' ', attrs = {}})
 | 
			
		||||
    end
 | 
			
		||||
    table.insert(rows, cols)
 | 
			
		||||
  end
 | 
			
		||||
  return rows
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function get_attr_id(attr_ids, attrs)
 | 
			
		||||
  if not attr_ids then
 | 
			
		||||
    return
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,69 @@ describe('Screen', function()
 | 
			
		||||
    screen:detach()
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  describe(':suspend', function()
 | 
			
		||||
    it('is forwarded to the UI', function()
 | 
			
		||||
      local function check()
 | 
			
		||||
        if not screen.suspended then
 | 
			
		||||
          return 'Screen was not suspended'
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      execute('suspend')
 | 
			
		||||
      screen:wait(check)
 | 
			
		||||
      screen.suspended = false
 | 
			
		||||
      feed('<c-z>')
 | 
			
		||||
      screen:wait(check)
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  describe('bell/visual bell', function()
 | 
			
		||||
    it('is forwarded to the UI', function()
 | 
			
		||||
      feed('<left>')
 | 
			
		||||
      screen:wait(function()
 | 
			
		||||
        if not screen.bell or screen.visual_bell then
 | 
			
		||||
          return 'Bell was not sent'
 | 
			
		||||
        end
 | 
			
		||||
      end)
 | 
			
		||||
      screen.bell = false
 | 
			
		||||
      execute('set visualbell')
 | 
			
		||||
      feed('<left>')
 | 
			
		||||
      screen:wait(function()
 | 
			
		||||
        if not screen.visual_bell or screen.bell then
 | 
			
		||||
          return 'Visual bell was not sent'
 | 
			
		||||
        end
 | 
			
		||||
      end)
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  describe(':set title', function()
 | 
			
		||||
    it('is forwarded to the UI', function()
 | 
			
		||||
      local expected = 'test-title'
 | 
			
		||||
      execute('set titlestring='..expected)
 | 
			
		||||
      execute('set title')
 | 
			
		||||
      screen:wait(function()
 | 
			
		||||
        local actual = screen.title
 | 
			
		||||
        if actual ~= expected then
 | 
			
		||||
          return 'Expected title to be "'..expected..'" but was "'..actual..'"'
 | 
			
		||||
        end
 | 
			
		||||
      end)
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  describe(':set icon', function()
 | 
			
		||||
    it('is forwarded to the UI', function()
 | 
			
		||||
      local expected = 'test-icon'
 | 
			
		||||
      execute('set iconstring='..expected)
 | 
			
		||||
      execute('set icon')
 | 
			
		||||
      screen:wait(function()
 | 
			
		||||
        local actual = screen.icon
 | 
			
		||||
        if actual ~= expected then
 | 
			
		||||
          return 'Expected title to be "'..expected..'" but was "'..actual..'"'
 | 
			
		||||
        end
 | 
			
		||||
      end)
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  describe('window', function()
 | 
			
		||||
    describe('split', function()
 | 
			
		||||
      it('horizontal', function()
 | 
			
		||||
@@ -95,6 +158,8 @@ describe('Screen', function()
 | 
			
		||||
                                                               |
 | 
			
		||||
        ]])
 | 
			
		||||
      end)
 | 
			
		||||
 | 
			
		||||
      
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
@@ -221,4 +286,193 @@ describe('Screen', function()
 | 
			
		||||
      feed('<cr>') --  skip the "Press ENTER..." state or tests will hang
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  describe('scrolling and clearing', function()
 | 
			
		||||
    before_each(function()
 | 
			
		||||
      insert([[
 | 
			
		||||
      Inserting
 | 
			
		||||
      text
 | 
			
		||||
      with
 | 
			
		||||
      many
 | 
			
		||||
      lines
 | 
			
		||||
      to
 | 
			
		||||
      test
 | 
			
		||||
      scrolling
 | 
			
		||||
      and
 | 
			
		||||
      clearing
 | 
			
		||||
      in
 | 
			
		||||
      split
 | 
			
		||||
      windows
 | 
			
		||||
      ]])
 | 
			
		||||
      execute('sp', 'vsp', 'vsp')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        and                 |and             |and            |
 | 
			
		||||
        clearing            |clearing        |clearing       |
 | 
			
		||||
        in                  |in              |in             |
 | 
			
		||||
        split               |split           |split          |
 | 
			
		||||
        windows             |windows         |windows        |
 | 
			
		||||
        ^                   |                |               |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]    [No Name] [+]  |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
    end)
 | 
			
		||||
 | 
			
		||||
    it('only affects the current scroll region', function()
 | 
			
		||||
      feed('6k')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        ^crolling           |and             |and            |
 | 
			
		||||
        and                 |clearing        |clearing       |
 | 
			
		||||
        clearing            |in              |in             |
 | 
			
		||||
        in                  |split           |split          |
 | 
			
		||||
        split               |windows         |windows        |
 | 
			
		||||
        windows             |                |               |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]    [No Name] [+]  |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
      feed('<c-w>l')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        scrolling           |and                 |and        |
 | 
			
		||||
        and                 |clearing            |clearing   |
 | 
			
		||||
        clearing            |in                  |in         |
 | 
			
		||||
        in                  |split               |split      |
 | 
			
		||||
        split               |windows             |windows    |
 | 
			
		||||
        windows             |^                   |           |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]        <Name] [+] |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
      feed('gg')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        scrolling           |^nserting           |and        |
 | 
			
		||||
        and                 |text                |clearing   |
 | 
			
		||||
        clearing            |with                |in         |
 | 
			
		||||
        in                  |many                |split      |
 | 
			
		||||
        split               |lines               |windows    |
 | 
			
		||||
        windows             |to                  |           |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]        <Name] [+] |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
      feed('7j')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        scrolling           |with                |and        |
 | 
			
		||||
        and                 |many                |clearing   |
 | 
			
		||||
        clearing            |lines               |in         |
 | 
			
		||||
        in                  |to                  |split      |
 | 
			
		||||
        split               |test                |windows    |
 | 
			
		||||
        windows             |^crolling           |           |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]        <Name] [+] |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
      feed('2j')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        scrolling           |lines               |and        |
 | 
			
		||||
        and                 |to                  |clearing   |
 | 
			
		||||
        clearing            |test                |in         |
 | 
			
		||||
        in                  |scrolling           |split      |
 | 
			
		||||
        split               |and                 |windows    |
 | 
			
		||||
        windows             |^learing            |           |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]        <Name] [+] |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
      feed('5k')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        scrolling           |^ines               |and        |
 | 
			
		||||
        and                 |to                  |clearing   |
 | 
			
		||||
        clearing            |test                |in         |
 | 
			
		||||
        in                  |scrolling           |split      |
 | 
			
		||||
        split               |and                 |windows    |
 | 
			
		||||
        windows             |clearing            |           |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]        <Name] [+] |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
      feed('k')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        scrolling           |^any                |and        |
 | 
			
		||||
        and                 |lines               |clearing   |
 | 
			
		||||
        clearing            |to                  |in         |
 | 
			
		||||
        in                  |test                |split      |
 | 
			
		||||
        split               |scrolling           |windows    |
 | 
			
		||||
        windows             |and                 |           |
 | 
			
		||||
        [No Name] [+]        [No Name] [+]        <Name] [+] |
 | 
			
		||||
        clearing                                             |
 | 
			
		||||
        in                                                   |
 | 
			
		||||
        split                                                |
 | 
			
		||||
        windows                                              |
 | 
			
		||||
                                                             |
 | 
			
		||||
        [No Name] [+]                                        |
 | 
			
		||||
                                                             |
 | 
			
		||||
      ]])
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
 | 
			
		||||
  describe('resize', function()
 | 
			
		||||
    before_each(function()
 | 
			
		||||
      screen:try_resize(25, 5)
 | 
			
		||||
      feed('iresize')
 | 
			
		||||
    end)
 | 
			
		||||
 | 
			
		||||
    it('rebuilds the whole screen', function()
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        resize^                  |
 | 
			
		||||
        ~                        |
 | 
			
		||||
        ~                        |
 | 
			
		||||
        ~                        |
 | 
			
		||||
        -- INSERT --             |
 | 
			
		||||
      ]])
 | 
			
		||||
    end)
 | 
			
		||||
 | 
			
		||||
    it('has minimum width/height values', function()
 | 
			
		||||
      screen:try_resize(1, 1)
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        -- INS^RT --|
 | 
			
		||||
                    |
 | 
			
		||||
      ]])
 | 
			
		||||
      feed('<esc>:ls')
 | 
			
		||||
      screen:expect([[
 | 
			
		||||
        resize      |
 | 
			
		||||
        :ls^        |
 | 
			
		||||
      ]])
 | 
			
		||||
    end)
 | 
			
		||||
  end)
 | 
			
		||||
end)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user