Skip to content

fix: resolve snippet line-context vars from caret#1354

Merged
sebthom merged 1 commit intoeclipse-lsp4e:mainfrom
sebthom:LSCompletionProposal
Oct 24, 2025
Merged

fix: resolve snippet line-context vars from caret#1354
sebthom merged 1 commit intoeclipse-lsp4e:mainfrom
sebthom:LSCompletionProposal

Conversation

@sebthom
Copy link
Copy Markdown
Member

@sebthom sebthom commented Oct 23, 2025

Compute $TM_LINE_INDEX, $TM_LINE_NUMBER, $TM_CURRENT_LINE from the viewer caret line instead of the TextEdit range.

Previously, variables were derived from the edit range, producing incorrect values when the caret was on a different line. Using the viewer caret aligns with snippet semantics and matches user expectations.

Compute $TM_LINE_INDEX, $TM_LINE_NUMBER, $TM_CURRENT_LINE from the
viewer caret line instead of the TextEdit range.

Previously, variables were derived from the edit range, producing
incorrect values when the caret was on a different line. Using the
viewer caret aligns with snippet semantics and matches user
expectations.
@rubenporras
Copy link
Copy Markdown
Contributor

How can it happen that the completion is asked in a different place than the one where the caret is placed? Can a user do that while he is working with the editor?

@sebthom
Copy link
Copy Markdown
Member Author

sebthom commented Oct 23, 2025

How can it happen that the completion is asked in a different place than the one where the caret is placed? Can a user do that while he is working with the editor?

An LSP server can return a completion with a textEdit range that differs from the caret position - for example, a multi-line selection/replacement that starts on a previous line. It can also use insert/replace ranges or additionalTextEdits to modify other locations (e.g., adding imports).

@sebthom sebthom merged commit 032f691 into eclipse-lsp4e:main Oct 24, 2025
11 checks passed
@sebthom sebthom deleted the LSCompletionProposal branch November 9, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants