Skip to content

Commit

Permalink
docs: add note about not being able to use ctx.cursor in luasnip source
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Dec 4, 2024
1 parent 5cfff34 commit 258fd39
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lua/blink/cmp/sources/luasnip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function source:execute(ctx, item)
if snip.regTrig then snip = snip:get_pattern_expand_helper() end

-- get (0, 0) indexed cursor position
-- the completion has been accepted by this point, so ctx.cursor is out of date
local cursor = vim.api.nvim_win_get_cursor(0)
cursor[1] = cursor[1] - 1

Expand Down

2 comments on commit 258fd39

@stefanboca
Copy link
Collaborator

@stefanboca stefanboca commented on 258fd39 Dec 5, 2024

Choose a reason for hiding this comment

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

@Saghen Should this actually be the case for all instances of source:execute? It looks like completions are always applied before execute is called. If so, this might be something good to add to the API docs when they're created.

@Saghen
Copy link
Owner Author

@Saghen Saghen commented on 258fd39 Dec 5, 2024

Choose a reason for hiding this comment

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

Good call, added it to #448 so I won't forget

Please sign in to comment.