Skip to content

fix: completion without textEdit removes the whitespace before the caret - #1667

Merged
angelozerr merged 1 commit into
redhat-developer:mainfrom
sergeysavchuk:993_completion_removes_leading_whitespace
Sep 14, 2026
Merged

angelozerr merged 1 commit into
redhat-developer:mainfrom
sergeysavchuk:993_completion_removes_leading_whitespace

Conversation

@sergeysavchuk

Copy link
Copy Markdown
Contributor

A completion item with only insertText (no textEdit) removes the whitespace
before the caret when it is applied on a blank line.

The prefix start comes from getWordRangeAt, which returns the PSI element at
offset - 1 — on a blank line, the whitespace leaf. The existing guard only
rejects a one character element, so "\n\n" or "\n " gets through and the
completion replaces it.

The fix returns null for whitespace, which also restores the documented
foo | bar -> null contract.

Fixes #993

Fixes redhat-developer#993

Signed-off-by: Siarhei Sauchuk <seregasavchuk@gmail.com>
@angelozerr

Copy link
Copy Markdown
Contributor

LGTM, thanks @sergeysavchuk !

@angelozerr
angelozerr merged commit 3bd9a7f into redhat-developer:main Sep 14, 2026
8 of 9 checks passed
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.

Simplest CompletionItem removes all leading whitespace

2 participants