Repository: neovim/neovim
File: test/functional/legacy/window_cmd_spec.lua (Lua)

Code before:
    screen:try_resize(40, 6)
    exec([[
      set splitkeep=screen nosplitbelow
      autocmd WinResized * call line('w0', 1000)
      call setline(1, range(1000))
    ]])
    screen:expect([[
      ^0                                       |
      1                                       |
      2                                       |
      3                                       |
      4                                       |
                                              |
    ]])
    feed(':wincmd s<CR>')
    screen:expect([[
      ^0                                       |
      1                                       |
      {3:[No Name] [+]                           }|
      3                                       |
      {2:[No Name] [+]                           }|
      :wincmd s                               |
    ]])
  end)

  it("'lines('w$') after nvim_win_set_height' (#36056)", function()
    local buf = api.nvim_create_buf(false, true)
    local opts = { width = 5, height = 1, col = 0, row = 0, relative = 'cursor' }
    local win = api.nvim_open_win(buf, false, opts)
    api.nvim_buf_set_lines(buf, 0, -1, true, { ('1'):rep(10), ('2'):rep(10) })
    local line = exec_lua(function()
      vim.api.nvim_win_set_height(win, vim.api.nvim_win_get_height(win) + 3)
      return vim.fn.line('w$', win)
    end)
    eq(2, line)
  end)
end)

-- oldtest: Test_winfixsize_vsep_statusline()
it("'winfixwidth/height' does not leave stray vseps/statuslines", function()
  clear()
  local screen = Screen.new(75, 8)
  exec([[
    set noequalalways splitbelow splitright
    vsplit
    setlocal winfixwidth
    vsplit
  ]])
  eq(16, fn.winwidth(1))
  eq(37, fn.winwidth(2))
  eq(20, fn.winwidth(3))

Review comment (suggestion):
```suggestion
  it("lines('w$') after nvim_win_set_height (#36056)", function()
```

Code after:
    exec([[
      set splitkeep=screen nosplitbelow
      autocmd WinResized * call line('w0', 1000)
      call setline(1, range(1000))
    ]])
    screen:expect([[
      ^0                                       |
      1                                       |
      2                                       |
      3                                       |
      4                                       |
                                              |
    ]])
    feed(':wincmd s<CR>')
    screen:expect([[
      ^0                                       |
      1                                       |
      {3:[No Name] [+]                           }|
      3                                       |
      {2:[No Name] [+]                           }|
      :wincmd s                               |
    ]])
  end)
end)

-- oldtest: Test_winfixsize_vsep_statusline()
it("'winfixwidth/height' does not leave stray vseps/statuslines", function()
  clear()
  local screen = Screen.new(75, 8)
  exec([[
    set noequalalways splitbelow splitright
    vsplit
    setlocal winfixwidth
    vsplit
  ]])
  eq(16, fn.winwidth(1))
  eq(37, fn.winwidth(2))
  eq(20, fn.winwidth(3))

  command('quit')
  screen:expect([[
    ^                                    │                                      |
    {1:~                                   }│{1:~                                     }|*5
    {3:[No Name]                            }{2:[No Name]                             }|
                                                                               |
  ]])
  -- Checks w_view_width in Nvim; especially important as the screen test may still pass if only
  -- w_width changed to make room for the vsep.
  eq(36, fn.winwidth(1))
  eq(38, fn.winwidth(2))