Skip to content

Commit

Permalink
fix: always get latest keyword
Browse files Browse the repository at this point in the history
Closes #539
  • Loading branch information
Saghen committed Dec 17, 2024
1 parent 1e4808e commit 13853d5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lua/blink/cmp/completion/list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ end

function list.fuzzy(context, items_by_source)
local fuzzy = require('blink.cmp.fuzzy')
local filtered_items = fuzzy.fuzzy(context:get_keyword(), items_by_source)
local filtered_items = fuzzy.fuzzy(context.get_keyword(), items_by_source)

-- apply the per source max_items
filtered_items = require('blink.cmp.sources.lib').apply_max_items_for_completions(context, filtered_items)
Expand Down
8 changes: 4 additions & 4 deletions lua/blink/cmp/completion/trigger/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
--- @field providers string[]
---
--- @field new fun(opts: blink.cmp.ContextOpts): blink.cmp.Context
--- @field get_keyword fun(self: blink.cmp.Context): string
--- @field get_keyword fun(): string
--- @field within_query_bounds fun(self: blink.cmp.Context, cursor: number[]): boolean
---
--- @field get_mode fun(): blink.cmp.Mode
Expand Down Expand Up @@ -59,10 +59,10 @@ function context.new(opts)
}, { __index = context })
end

function context:get_keyword()
function context.get_keyword()
local keyword = require('blink.cmp.config').completion.keyword
local range = self.get_regex_around_cursor(keyword.range, keyword.regex, keyword.exclude_from_prefix_regex)
return string.sub(self.line, range.start_col, range.start_col + range.length - 1)
local range = context.get_regex_around_cursor(keyword.range, keyword.regex, keyword.exclude_from_prefix_regex)
return string.sub(context.get_line(), range.start_col, range.start_col + range.length - 1)
end

--- @param cursor number[]
Expand Down
2 changes: 1 addition & 1 deletion lua/blink/cmp/completion/windows/render/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ local draw_context = {}
--- @return blink.cmp.DrawItemContext[]
function draw_context.get_from_items(context, draw, items)
local matched_indices = require('blink.cmp.fuzzy').fuzzy_matched_indices(
context:get_keyword(),
context.get_keyword(),
vim.tbl_map(function(item) return item.label end, items)
)

Expand Down

0 comments on commit 13853d5

Please sign in to comment.