Skip to content

Commit 92918cf

Browse files
committed
bugfix for #379
1 parent ed18c00 commit 92918cf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lua/easycomplete/cmdline.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ function this.calculate_sign_and_linenr_width()
8080
return width
8181
end
8282

83+
function this.window_offset_horizontal()
84+
local offset = vim.fn.win_screenpos(vim.fn.win_getid())
85+
local offset_horizontal = offset[2]
86+
return offset_horizontal - 1
87+
end
88+
8389
function this.safe_redraw()
8490
if vim.fn.has('nvim-0.10') then
8591
vim.api.nvim__redraw({
@@ -523,7 +529,10 @@ end
523529
-- 根据某个正则表达式是否匹配,来调用既定的get_cmp_items,并执行complete()
524530
function this.cmp_regex_handler(get_cmp_items, word)
525531
local should_redraw = false
526-
local start_col = vim.fn.getcmdpos() - this.calculate_sign_and_linenr_width() - #word
532+
local start_col = vim.fn.getcmdpos()
533+
- this.calculate_sign_and_linenr_width()
534+
- #word
535+
- this.window_offset_horizontal()
527536
cmdline_start_cmdpos = vim.fn.getcmdpos() - #word
528537
local ok, menu_items = pcall(get_cmp_items)
529538
if not ok then

0 commit comments

Comments
 (0)