mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(screenpos, float): add top and left border adjustment
This commit is contained in:
parent
14ffcd190d
commit
ffe3003e02
@ -1011,7 +1011,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
||||
col -= wp->w_leftcol;
|
||||
|
||||
if (col >= 0 && col < wp->w_width) {
|
||||
coloff = col - scol + (local ? 0 : wp->w_wincol) + 1;
|
||||
coloff = col - scol + (local ? 0 : wp->w_wincol + wp->w_border_adj[3]) + 1;
|
||||
} else {
|
||||
scol = ccol = ecol = 0;
|
||||
// character is left or right of the window
|
||||
@ -1022,7 +1022,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
||||
}
|
||||
}
|
||||
}
|
||||
*rowp = (local ? 0 : wp->w_winrow) + row + rowoff;
|
||||
*rowp = (local ? 0 : wp->w_winrow + wp->w_border_adj[0]) + row + rowoff;
|
||||
*scolp = scol + coloff;
|
||||
*ccolp = ccol + coloff;
|
||||
*ecolp = ecol + coloff;
|
||||
|
51
test/functional/vimscript/screenpos_spec.lua
Normal file
51
test/functional/vimscript/screenpos_spec.lua
Normal file
@ -0,0 +1,51 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths
|
||||
local command, funcs = helpers.command, helpers.funcs
|
||||
|
||||
before_each(clear)
|
||||
|
||||
describe('screenpos() function', function()
|
||||
it('works in floating window with border', function()
|
||||
local bufnr = meths.create_buf(false, true)
|
||||
local opts = {
|
||||
relative='editor',
|
||||
height=8,
|
||||
width=12,
|
||||
row=6,
|
||||
col=8,
|
||||
anchor='NW',
|
||||
style='minimal',
|
||||
border='none',
|
||||
focusable=1
|
||||
}
|
||||
local float = meths.open_win(bufnr, false, opts)
|
||||
command('redraw')
|
||||
local pos = funcs.screenpos(bufnr, 1, 1)
|
||||
eq(7, pos.row)
|
||||
eq(9, pos.col)
|
||||
|
||||
-- only left border
|
||||
opts.border = {'', '', '', '', '', '', '', '|'}
|
||||
meths.win_set_config(float, opts)
|
||||
command('redraw')
|
||||
pos = funcs.screenpos(bufnr, 1, 1)
|
||||
eq(7, pos.row)
|
||||
eq(10, pos.col)
|
||||
|
||||
-- only top border
|
||||
opts.border = {'', '_', '', '', '', '', '', ''}
|
||||
meths.win_set_config(float, opts)
|
||||
command('redraw')
|
||||
pos = funcs.screenpos(bufnr, 1, 1)
|
||||
eq(8, pos.row)
|
||||
eq(9, pos.col)
|
||||
|
||||
-- both left and top border
|
||||
opts.border = 'single'
|
||||
meths.win_set_config(float, opts)
|
||||
command('redraw')
|
||||
pos = funcs.screenpos(bufnr, 1, 1)
|
||||
eq(8, pos.row)
|
||||
eq(10, pos.col)
|
||||
end)
|
||||
end)
|
Loading…
Reference in New Issue
Block a user