Skip to content

Commit

Permalink
fix(cmdline): properly compute string length (#1544)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilshvalov committed May 1, 2023
1 parent 5dcbc91 commit 524cc0b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/cmp/view/custom_entries_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ custom_entries_view._insert = setmetatable({
local current_line = api.get_current_line()
local before_line = current_line:sub(1, self.offset - 1)
local after_line = current_line:sub(cursor[2] + 1)
local pos = vim.fn.strdisplaywidth(before_line .. word) + 1
local pos = #before_line + #word + 1
vim.fn.setcmdline(before_line .. word .. after_line, pos)
vim.api.nvim_feedkeys(keymap.t('<Cmd>redraw<CR>'), 'ni', false)
else
Expand Down

1 comment on commit 524cc0b

@3719e04
Copy link

@3719e04 3719e04 commented on 524cc0b May 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change has caused a bug with cmp.mapping.confirm. After this commit, all completion after a leading . will duplicate the first character.

For example, in C++

data.f<|> // after `cmp.mapping.confirm`, this line becomes `data.fieldf`

where <|> is the caret.

Please sign in to comment.