LSP: Improve insertion algorithm for resolving completion options#113031
Merged
Repiteo merged 1 commit intogodotengine:masterfrom Nov 25, 2025
Merged
Conversation
642ef89 to
14cde0f
Compare
akien-mga
approved these changes
Nov 25, 2025
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes godotengine/godot-vscode-plugin#891
Fixes godotengine/godot-vscode-plugin#842
(The fixes comments are a bit hard to say for sure, since there are also some very inconsistent cases with outdated content in the LSP which can result in the same symptoms. See #105236 for fixes to those cases. Anyway this PR should fix the most common origin of the symptoms.)
Supersedes #107865
The approach from this PR fixes an additional edge case which the PR mentioned above does not fix:
The code is basically iterating increasingly big prefixes left of the cursor. And if those prefixes happen to be prefixes of the symbol the symbol gets insert-merged into the line.
The issue is, that if no prefix matches, the code would just continue without inserting the symbol at all. (This is a very simplified explanation! The original source right of the cursor always stays untouched so some very specific conditions are needed for an issue to occur.)
The older PR tried to solve this by starting iteration one character right of the cursor to ensure there would always be a matching prefix. This PR instead falls back to just inserting the symbol in place, if there was no match.
I also added a comment trying to add some context to what this code is trying to do and why correctness isn't the highest priority.