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

Code before:
        feed('<C-E><ESC>')
      end)

      it('popup info window reuses bufnr', function()
        feed('S<C-x><C-o><C-N>')
        eq(1, n.eval([[len(uniq(copy(g:bufnrs))) == 1]]))
      end)

      it('handles tabs in info width calculation', function()
        screen:try_resize(50, 11)
        command([[
          set cot+=menuone
          let g:list = [#{word: 'class', info: "\tClassName() = default;"}]
        ]])
        feed('S<C-x><C-o>')
        local info = fn.complete_info()
        eq(30, api.nvim_win_get_width(info.preview_winid))
        feed('<ESC>')
        exec([[
          setlocal tabstop=1
          autocmd ModeChanged *:i ++once call complete(1, [#{word: 'a'}])
                \| call nvim__complete_set(0, #{info: "\tfloob\tfloob"})
        ]])
        feed('i')
        info = fn.complete_info()
        eq(12, api.nvim_win_get_width(info.preview_winid))
      end)

      it('hide info window when insufficient space', function()
        screen:try_resize(12, 11)
        feed('S<C-x><C-o>')
        local info = fn.complete_info()
        eq(true, api.nvim_win_get_config(info.preview_winid).hide)
      end)
    end)

    it('with vsplits', function()
      screen:try_resize(32, 8)
      insert('aaa aab aac\n')
      feed(':vsplit<cr>')
      if multigrid then
        screen:expect([[
        ## grid 1
          [4:--------------------]│[2:-----------]|*6
          {3:[No Name] [+]        }{2:<Name] [+] }|
          [3:--------------------------------]|
        ## grid 2
          aaa aab aac|
                     |
          {1:~          }|*4
        ## grid 3

Review comment (bug):
```suggestion
        eq(21, api.nvim_win_get_width(info.preview_winid))
```

After making the other change, this should be 21. (default of `&ts=8` aligns the end of the 2nd tab to column 16)

(Note that expecting 12 here would've also passed with the prior buggy behaviour of `linetabsize_str` in https://github.com/neovim/neovim/commit/3ce9f63c498f4d5d11f3d67baa237fab46c52f5c, so maybe also add a screen test here to ensure the text isn't wrapped?)

Code after:
        feed('<C-E><ESC>')
      end)

      it('popup info window reuses bufnr', function()
        feed('S<C-x><C-o><C-N>')
        eq(1, n.eval([[len(uniq(copy(g:bufnrs))) == 1]]))
      end)

      it('handles tabs in info width calculation', function()
        screen:try_resize(50, 11)
        command([[
          set cot+=menuone
          let g:list = [#{word: 'class', info: "\tClassName() = default;"}]
        ]])
        feed('S<C-x><C-o>')
        local info = fn.complete_info()
        eq(30, api.nvim_win_get_width(info.preview_winid))
        feed('<ESC>')
        exec([[
          setlocal tabstop=1
          autocmd ModeChanged *:i ++once call complete(1, [#{word: 'a'}])
                \| call nvim__complete_set(0, #{info: "\tfloob\tfloob"})
        ]])
        feed('i')
        info = fn.complete_info()
        eq(21, api.nvim_win_get_width(info.preview_winid))
        if not multigrid then
          screen:expect([[
            a^s                                                |
            {12:a              }{n:        floob   floob}{1:              }|
            {1:~                                                 }|*8
            {5:-- INSERT --}                                      |
          ]])
        end
      end)

      it('hide info window when insufficient space', function()
        screen:try_resize(12, 11)
        feed('S<C-x><C-o>')
        local info = fn.complete_info()
        eq(true, api.nvim_win_get_config(info.preview_winid).hide)
      end)
    end)

    it('with vsplits', function()
      screen:try_resize(32, 8)
      insert('aaa aab aac\n')
      feed(':vsplit<cr>')
      if multigrid then
        screen:expect([[
        ## grid 1