Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit bdf4f08

Browse files
author
iguanacucumber
committed
upstream: typos + #2414
1 parent cf8afed commit bdf4f08

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

lua/cmp/config/compare.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ compare.recently_used = setmetatable({
6666
end,
6767
})
6868

69-
---kind: Entires with smaller ordinal value of 'kind' will be ranked higher.
69+
---kind: Entries with smaller ordinal value of 'kind' will be ranked higher.
7070
---(see lsp.CompletionItemKind enum).
7171
---Exceptions are that Text(1) will be ranked the lowest, and snippets be the highest.
7272
---@type cmp.ComparatorFunction
@@ -106,7 +106,7 @@ compare.sort_text = function(entry1, entry2)
106106
return nil
107107
end
108108

109-
---length: Entires with shorter label length will be ranked higher.
109+
---length: Entries with shorter label length will be ranked higher.
110110
---@type cmp.ComparatorFunction
111111
compare.length = function(entry1, entry2)
112112
local diff = #entry1.completion_item.label - #entry2.completion_item.label

lua/cmp/core.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,11 @@ core.confirm = function(self, e, option, callback)
441441
return
442442
end
443443
vim.cmd([[silent! undojoin]])
444-
vim.lsp.util.apply_text_edits(text_edits, ctx.bufnr, e.source:get_position_encoding_kind())
444+
api.apply_text_edits(text_edits, ctx.bufnr, e.source:get_position_encoding_kind())
445445
end)
446446
else
447447
vim.cmd([[silent! undojoin]])
448-
vim.lsp.util.apply_text_edits(e.completion_item.additionalTextEdits, ctx.bufnr, e.source:get_position_encoding_kind())
448+
api.apply_text_edits(e.completion_item.additionalTextEdits, ctx.bufnr, e.source:get_position_encoding_kind())
449449
end
450450
end)
451451
feedkeys.call('', 'n', function()

lua/cmp/entry.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ entry._get_view = function(self, item, entries_buf)
290290
view.menu.hl_group = item.menu_hl_group or 'CmpItemMenu'
291291
view.dup = item.dup
292292
end)
293+
293294
return view
294295
end
295296

lua/cmp/utils/api.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,15 @@ api.get_cursor_before_line = function()
6767
return string.sub(api.get_current_line(), 1, cursor[2])
6868
end
6969

70+
--- Applies a list of text edits to a buffer. Preserves 'buflisted' state.
71+
---@param text_edits lsp.TextEdit[]
72+
---@param bufnr integer Buffer id
73+
---@param position_encoding 'utf-8'|'utf-16'|'utf-32'
74+
api.apply_text_edits = function(text_edits, bufnr, position_encoding)
75+
-- preserve 'buflisted' state because vim.lsp.util.apply_text_edits forces it to true
76+
local prev_buflisted = vim.bo[bufnr].buflisted
77+
vim.lsp.util.apply_text_edits(text_edits, bufnr, position_encoding)
78+
vim.bo[bufnr].buflisted = prev_buflisted
79+
end
80+
7081
return api

0 commit comments

Comments
 (0)