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

Code before:
            bottom = 0,
            left = 0,
            right = 0,
            top = 0,
            win = 1000
          },
          [4] = {
            bottom = 0,
            left = 0,
            right = 0,
            top = 0,
            win = 1001
          }
        }
        })
      else
        screen:expect({
          grid = [[
                                                    |
            {0:~                                       }|*5
                                                    |
          ]]
        })
      end

      -- show cursor in cmdline when jump into cmdline from a hidden floating window
      feed(':')
      if multigrid then
        screen:expect({
          grid = [[
          ## grid 1
            [2:----------------------------------------]|*6
            [3:----------------------------------------]|
          ## grid 2
                                                    |
            {0:~                                       }|*5
          ## grid 3
            :^                                       |
          ## grid 4 (hidden)
            {1:          }|
            {2:~         }|
          ]], win_viewport={
          [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
          [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
        }, win_viewport_margins={
          [2] = {
            bottom = 0,
            left = 0,
            right = 0,
            top = 0,
            win = 1000

Review comment (suggestion):
```suggestion
      -- Show cursor if cmdline is entered while curwin is a hide=true floating window.
```

Code after:
    end)

    describe('no crash after moving and closing float window #21547', function()
      local function test_float_move_close(cmd)
        local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
        api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts)
        if multigrid then
          screen:expect({float_pos = {[4] = {1001, 'NW', 1, 1, 1, true, 50, 1, 0, 1}}})
        end
        command(cmd)
        exec_lua([[
          vim.api.nvim_win_set_config(0, {relative = 'editor', row = 2, col = 2})
          vim.api.nvim_win_close(0, {})
          vim.api.nvim_echo({{''}}, false, {})
        ]])
        if multigrid then
          screen:expect({float_pos = {}})
        end
        assert_alive()
      end

      it('if WinClosed autocommand flushes UI', function()
        test_float_move_close('autocmd WinClosed * ++once redraw')
      end)

      it('if closing buffer flushes UI', function()
        test_float_move_close('autocmd BufWinLeave * ++once redraw')
      end)
    end)

    it(':sleep cursor placement #22639', function()
      local float_opts = {relative = 'editor', row = 1, col = 1, width = 4, height = 3}
      local win = api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts)
      feed('iab<CR>cd<Esc>')
      feed(':sleep 100')
      if multigrid then
        screen:expect{grid=[[
        ## grid 1
          [2:----------------------------------------]|*6
          [3:----------------------------------------]|
        ## grid 2
                                                  |
          {0:~                                       }|*5
        ## grid 3
          :sleep 100^                              |
        ## grid 4
          {1:ab  }|
          {1:cd  }|
          {2:~   }|
        ]], float_pos={
          [4] = {1001, "NW", 1, 1, 1, true, 50, 1, 1, 1};