Repository: neovim/neovim
File: test/functional/ui/float_spec.lua (Lua)

Code before:
    local float_opts = { style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1 }
    local float_win = api.nvim_open_win(0, true, float_opts)
    api.nvim_set_option_value('number', true, { win = float_win })
    float_opts.row = 2
    api.nvim_win_set_config(float_win, float_opts)
    eq(false, api.nvim_get_option_value('number', { win = float_win }))
  end)

  it("should not re-apply 'style' when missing", function()
    local float_opts = { style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1 }
    local float_win = api.nvim_open_win(0, true, float_opts)
    api.nvim_set_option_value('number', true, { win = float_win })
    float_opts.row = 2
    float_opts.style = nil
    api.nvim_win_set_config(float_win, float_opts)
    eq(true, api.nvim_get_option_value('number', { win = float_win }))
  end)

  it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function()
    api.nvim_set_option_value('splitkeep', 'screen', {})
    local float_opts = { relative = 'editor', row = 1, col = 1, width = 10, height = 10 }
    local float_win = api.nvim_open_win(0, true, float_opts)
    eq(5, api.nvim_get_option_value('scroll', { win = float_win }))
  end)

  it("lines('w$') is computed correctly after nvim_win_set_height with 'splitkeep=screen' #36056", function()
    api.nvim_set_option_value('splitkeep', 'screen', {})
    local buf = api.nvim_create_buf(false, true)
    local win = api.nvim_open_win(buf, false, { width = 5, height = 1, col = 0, row = 0, relative = 'cursor' })
    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)

  it(':unhide works when there are floating windows', function()
    local float_opts = { relative = 'editor', row = 1, col = 1, width = 5, height = 5 }
    local w0 = curwin()
    api.nvim_open_win(0, false, float_opts)
    api.nvim_open_win(0, false, float_opts)
    eq(3, #api.nvim_list_wins())
    command('unhide')
    eq({ w0 }, api.nvim_list_wins())
  end)

  it(':all works when there are floating windows', function()
    command('args Xa.txt')
    local float_opts = { relative = 'editor', row = 1, col = 1, width = 5, height = 5 }
    local w0 = curwin()

Review comment (suggestion):
all tests are assumed to test correctness.

```suggestion
  it("lines('w$') after nvim_win_set_height with 'splitkeep=screen' #36056", function()
```

Code after:
    local float_opts = { style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1 }
    local float_win = api.nvim_open_win(0, true, float_opts)
    api.nvim_set_option_value('number', true, { win = float_win })
    float_opts.row = 2
    api.nvim_win_set_config(float_win, float_opts)
    eq(false, api.nvim_get_option_value('number', { win = float_win }))
  end)

  it("should not re-apply 'style' when missing", function()
    local float_opts = { style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1 }
    local float_win = api.nvim_open_win(0, true, float_opts)
    api.nvim_set_option_value('number', true, { win = float_win })
    float_opts.row = 2
    float_opts.style = nil
    api.nvim_win_set_config(float_win, float_opts)
    eq(true, api.nvim_get_option_value('number', { win = float_win }))
  end)

  it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function()
    api.nvim_set_option_value('splitkeep', 'screen', {})
    local float_opts = { relative = 'editor', row = 1, col = 1, width = 10, height = 10 }
    local float_win = api.nvim_open_win(0, true, float_opts)
    eq(5, api.nvim_get_option_value('scroll', { win = float_win }))
  end)

  it("lines('w$') after nvim_win_set_height with 'splitkeep=screen' #36056", function()
    api.nvim_set_option_value('splitkeep', 'screen', {})
    local buf = api.nvim_create_buf(false, true)
    local win = api.nvim_open_win(buf, false, { width = 5, height = 1, col = 0, row = 0, relative = 'cursor' })
    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)

  it(':unhide works when there are floating windows', function()
    local float_opts = { relative = 'editor', row = 1, col = 1, width = 5, height = 5 }
    local w0 = curwin()
    api.nvim_open_win(0, false, float_opts)
    api.nvim_open_win(0, false, float_opts)
    eq(3, #api.nvim_list_wins())
    command('unhide')
    eq({ w0 }, api.nvim_list_wins())
  end)

  it(':all works when there are floating windows', function()
    command('args Xa.txt')
    local float_opts = { relative = 'editor', row = 1, col = 1, width = 5, height = 5 }
    local w0 = curwin()