Use get_word so that the word is the same as in core.confirm#1860
Use get_word so that the word is the same as in core.confirm#1860luozhiya wants to merge 1 commit intohrsh7th:mainfrom
get_word so that the word is the same as in core.confirm#1860Conversation
|
This only works if there's a I've came up with another attempt to fix the same issue: diff --git a/lua/cmp/view/ghost_text_view.lua b/lua/cmp/view/ghost_text_view.lua
index 19c9513..1af7ad9 100644
--- a/lua/cmp/view/ghost_text_view.lua
+++ b/lua/cmp/view/ghost_text_view.lua
@@ -88,6 +88,12 @@ ghost_text_view.text_gen = function(self, line, cursor_col)
if self.entry:get_completion_item().insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = tostring(snippet.parse(word))
end
+
+ local irange = self.entry:get_insert_range()
+ if irange and self.entry.source_insert_range.start.line == irange.start.line then
+ word = string.sub(line, self.entry:get_offset(), irange.start.character) .. word
+ end
+
local word_clen = vim.str_utfindex(word)
local cword = string.sub(line, self.entry:get_offset(), cursor_col)
local cword_clen = vim.str_utfindex(cword)
Since {
label = "service_command(service_name)",
labelDetails = {},
textEdit = {
newText = "ice_command(",
range = {
["end"] = {
character = 12,
line = 456
},
start = {
character = 12,
line = 456
}
}
}
}This is after typing "serv" and triggering completions. (Also, with such textEdits, replacing is completely broken because of the silly heuristic introduced in #1177) |
Problem
Build a
CompletionResponsein the following way:When
cursor_before_lineiseandsuggestionsismail, ghost_text will showailand will be missing a characterm.However, when you preview it from
<Tab>, themailis displayed correctly.Solution
Use
get_wordso that the word is the same as incore.confirm