Skip to content

Commit

Permalink
feat(perf): call score_offset func once per source
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Oct 28, 2024
1 parent bc311b7 commit bd90e00
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lua/blink/cmp/sources/lib/provider/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ function source:get_completions(context, enabled_sources)
if response == nil then response = { is_incomplete_forward = true, is_incomplete_backward = true, items = {} } end
response.context = context

-- add non-lsp meta
-- add non-lsp metadata
local source_score_offset = self.config.score_offset(context, enabled_sources) or 0
for _, item in ipairs(response.items) do
item.score_offset = (item.score_offset or 0) + (self.config.score_offset(context, enabled_sources) or 0)
item.score_offset = (item.score_offset or 0) + source_score_offset
item.cursor_column = context.cursor[2]
item.source_id = self.id
item.source_name = self.name
Expand Down

0 comments on commit bd90e00

Please sign in to comment.