neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

screenrowcol_spec.lua (1752B)


      1 local t = require('test.testutil')
      2 local n = require('test.functional.testnvim')()
      3 local Screen = require('test.functional.ui.screen')
      4 
      5 local clear, eq, api = n.clear, t.eq, n.api
      6 local command, fn = n.command, n.fn
      7 local feed = n.feed
      8 
      9 describe('screenrow() and screencol() function', function()
     10  local function with_ext_multigrid(multigrid)
     11    before_each(function()
     12      clear()
     13      Screen.new(41, 41, { ext_multigrid = multigrid })
     14    end)
     15 
     16    pending('works in floating window', function()
     17      local opts = {
     18        relative = 'editor',
     19        height = 8,
     20        width = 12,
     21        row = 6,
     22        col = 8,
     23        anchor = 'NW',
     24        style = 'minimal',
     25        border = 'none',
     26        focusable = 1,
     27      }
     28      local float = api.nvim_open_win(api.nvim_create_buf(false, true), false, opts)
     29 
     30      api.nvim_set_current_win(float)
     31      command('redraw')
     32 
     33      eq(7, fn.screenrow())
     34      eq(9, fn.screencol())
     35    end)
     36 
     37    pending('works in vertical split', function()
     38      command('vsplit')
     39      command('wincmd l') -- move to right split
     40      feed('iA<CR>BC<ESC>') -- insert two lines
     41      command('redraw')
     42 
     43      eq(2, fn.screenrow())
     44      eq(23, fn.screencol()) -- 20 (left) | 1 (border) | 2 (2nd col)
     45    end)
     46 
     47    pending('works in horizontal split', function()
     48      command('split')
     49      command('wincmd j') -- move to bottom split
     50      feed('iA<CR>BC<ESC>') -- insert two lines
     51      command('redraw')
     52 
     53      eq(22, fn.screenrow()) -- 19 (top) | 1 (border) | 2 (2nd row) + 17 (rest) | 2 (cmd)
     54      eq(2, fn.screencol())
     55    end)
     56  end
     57 
     58  describe('with ext_multigrid', function()
     59    with_ext_multigrid(true)
     60  end)
     61 
     62  describe('without ext_multigrid', function()
     63    with_ext_multigrid(false)
     64  end)
     65 end)