vis: fast-jump: add proper padding for windows in horizontal and vertical splits
This commit is contained in:
@@ -46,12 +46,34 @@ local function merge(a, b)
|
||||
end
|
||||
|
||||
local function padding()
|
||||
local l, r, t, n = 0, 0, 0, 0
|
||||
local opt = vis.win.options
|
||||
local l = 0
|
||||
if opt.numbers or opt.relativenumbers then
|
||||
l = #tostring(vis.win.viewport.lines.finish)
|
||||
n = #tostring(vis.win.viewport.lines.finish)
|
||||
end
|
||||
return '0,0,0,' .. l
|
||||
if vis.ui.layout == vis.ui.layouts.HORIZONTAL then
|
||||
for win in vis:windows() do
|
||||
if win == vis.win then
|
||||
break
|
||||
end
|
||||
t = t + win.height
|
||||
end
|
||||
elseif vis.ui.layout == vis.ui.layouts.VERTICAL then
|
||||
local left = true
|
||||
for win in vis:windows() do
|
||||
if win == vis.win then
|
||||
left = false
|
||||
if opt.wrapcolumn ~= 0 then
|
||||
r = r + win.width - n - opt.wrapcolumn
|
||||
end
|
||||
elseif left then
|
||||
l = l + win.width + 1
|
||||
else
|
||||
r = r + win.width
|
||||
end
|
||||
end
|
||||
end
|
||||
return t .. ',' .. r .. ',0,' .. (l + n)
|
||||
end
|
||||
|
||||
local mu = #up_keys
|
||||
@@ -146,7 +168,7 @@ local function jump(keys)
|
||||
end
|
||||
input = input .. data:sub(k)
|
||||
|
||||
local code, out, err = vis:pipe(input, 'fzf --ansi --layout=reverse-list --no-info --no-separator --color gutter:-1 --marker="" --padding ' .. padding() .. ' --print-query --bind change:accept')
|
||||
local code, out, err = vis:pipe(input, 'fzf --ansi --layout=reverse-list --no-info --no-separator --color gutter:-1 --marker="" --wrap --padding ' .. padding() .. ' --print-query --bind change:accept')
|
||||
if code ~= 0 then
|
||||
vis:info(err or ('fzf exit code ' .. code))
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user