screenpos_spec.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths
  3. local command, funcs = helpers.command, helpers.funcs
  4. before_each(clear)
  5. describe('screenpos() function', function()
  6. it('works in floating window with border', function()
  7. local bufnr = meths.create_buf(false, true)
  8. local opts = {
  9. relative='editor',
  10. height=8,
  11. width=12,
  12. row=6,
  13. col=8,
  14. anchor='NW',
  15. style='minimal',
  16. border='none',
  17. focusable=1
  18. }
  19. local float = meths.open_win(bufnr, false, opts)
  20. command('redraw')
  21. local pos = funcs.screenpos(bufnr, 1, 1)
  22. eq(7, pos.row)
  23. eq(9, pos.col)
  24. -- only left border
  25. opts.border = {'', '', '', '', '', '', '', '|'}
  26. meths.win_set_config(float, opts)
  27. command('redraw')
  28. pos = funcs.screenpos(bufnr, 1, 1)
  29. eq(7, pos.row)
  30. eq(10, pos.col)
  31. -- only top border
  32. opts.border = {'', '_', '', '', '', '', '', ''}
  33. meths.win_set_config(float, opts)
  34. command('redraw')
  35. pos = funcs.screenpos(bufnr, 1, 1)
  36. eq(8, pos.row)
  37. eq(9, pos.col)
  38. -- both left and top border
  39. opts.border = 'single'
  40. meths.win_set_config(float, opts)
  41. command('redraw')
  42. pos = funcs.screenpos(bufnr, 1, 1)
  43. eq(8, pos.row)
  44. eq(10, pos.col)
  45. end)
  46. end)