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

Code before:
            three                                   |
            {0:~                                       }|*3
          ## grid 3
                                                    |
          ## grid 4
            {1:the only line       }|
            {1:                    }|
          ## grid 5
            {1:highest}|
            {1:       }|
          ## grid 6
            {1:^another}|
            {1:       }|
          ]],
          win_pos = {
            [2] = { height = 6, startcol = 0, startrow = 0, width = 40, win = 1000 },
          },
          float_pos = {
            [4] = { 1001, 'NW', 1, 0, 0, true, 50, 1, 0, 0 },
            [5] = { 1002, 'NW', 1, 0, 0, true, 150, 2, 0, 0 },
            [6] = { 1003, 'NW', 1, 0, 0, true, 160, 3, 0, 0 },
          },
          mode = 'normal',
        })
      else
        screen:expect { mode = 'normal' }
      end
      api.nvim_set_current_win(normal_win)
      command('only')
      screen:try_resize(50, 20)
      buf = api.nvim_create_buf(false, false)
      api.nvim_buf_set_lines(buf, 0, -1, true, { 'x' })
      local float_win = api.nvim_open_win(buf, true, {
        relative = 'editor',
        width = 5,
        height = 5,
        row = 8,
        col = 9,
        border = 'single',
        zindex = 1,
      })
      local buf2 = api.nvim_create_buf(false, false)
      api.nvim_open_win(buf2, false, {
        relative = 'editor',
        width = 10,
        height = 10,
        row = 0,
        col = 0,
        zindex = 2,
      })
      if multigrid then

Review comment (bug):
Because the full screen state isn't being asserted, this passes immediately with the old (incorrect) state before the redraw happens (because the expected cursor `mode` is the same as the previous `expect`). You can observe this with `screen:redraw_debug()`.

Might be a good idea to instead assert the new screen state in these cases:

```
warning: Screen test succeeded immediately. Try to avoid this unless the
purpose of the test really requires it.
If necessary, silence this warning with 'unchanged' argument of screen:expect.
stack traceback:
        test/functional/ui/screen.lua:912: in function '_wait'
        test/functional/ui/screen.lua:537: in function 'expect'
        test/functional/ui/float_spec.lua:11429: in function <test/functional/ui/float_spec.lua:11255>


warning: Screen test succeeded immediately. Try to avoid this unless the
purpose of the test really requires it.
If necessary, silence this warning with 'unchanged' argument of screen:expect.
stack traceback:
        test/functional/ui/screen.lua:912: in function '_wait'
        test/functional/ui/screen.lua:537: in function 'expect'
        test/functional/ui/float_spec.lua:11486: in function <test/functional/ui/float_spec.lua:11255>


warning: Screen test succeeded immediately. Try to avoid this unless the
purpose of the test really requires it.
If necessary, silence this warning with 'unchanged' argument of screen:expect.
stack traceback:
        test/functional/ui/screen.lua:912: in function '_wait'
        test/functional/ui/screen.lua:537: in function 'expect'
        test/functional/ui/float_spec.lua:11522: in function <test/functional/ui/float_spec.lua:11255>


warning: Screen test succeeded immediately. Try to avoid this unless the
purpose of the test really requires it.
There are intermediate states between the two identical expects.
Use screen:snapshot_util() or screen:redraw_debug() to find them, and add them
to the test if they make sense.

stack traceback:
        test/functional/ui/screen.lua:912: in function '_wait'
        test/functional/ui/screen.lua:537: in function 'expect'
        test/functional/ui/float_spec.lua:11560: in function <test/functional/ui/float_spec.lua:11255>
```

Code after:
        ]],
          mode = 'normal',
        }
      end

      buf = api.nvim_create_buf(false, false)
      api.nvim_buf_set_lines(buf, 0, 0, true, { 'another' })
      api.nvim_open_win(buf, true, { relative = 'editor', row = 0, col = 0, height = 2, width = 7, zindex = 160 })
      if multigrid then
        screen:expect({
          grid = [[
          ## grid 1
            [2:----------------------------------------]|*6
            [3:----------------------------------------]|
          ## grid 2
            one                                     |
            two                                     |
            three                                   |
            {0:~                                       }|*3
          ## grid 3
                                                    |
          ## grid 4
            {1:the only line       }|
            {1:                    }|
          ## grid 5
            {1:highest}|
            {1:       }|
          ## grid 6
            {1:^another}|
            {1:       }|
          ]],
          win_pos = {
            [2] = { height = 6, startcol = 0, startrow = 0, width = 40, win = 1000 },
          },
          float_pos = {
            [4] = { 1001, 'NW', 1, 0, 0, true, 50, 1, 0, 0 },
            [5] = { 1002, 'NW', 1, 0, 0, true, 150, 2, 0, 0 },
            [6] = { 1003, 'NW', 1, 0, 0, true, 160, 3, 0, 0 },
          },
          mode = 'normal',
        })
      else
        screen:expect {
          grid = [[
          {1:^anothery line       }                    |
          {1:                    }                    |
          three                                   |
          {0:~                                       }|*3
                                                  |
        ]],
          mode = 'normal',