-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: only use optionalReplacementSpan if client supports InsertReplace #584
Conversation
@@ -63,7 +63,7 @@ export function asCompletionItem(entry: tsp.CompletionEntry, optionalReplacement | |||
} | |||
|
|||
let insertText = entry.insertText; | |||
const replacementSpan = entry.replacementSpan || optionalReplacementSpan; | |||
const replacementSpan = entry.replacementSpan || (features.completionInsertReplaceSupport ? optionalReplacementSpan : undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest removing unnecessary code bellow:
- const replacementSpan = entry.replacementSpan || (features.completionInsertReplaceSupport ? optionalReplacementSpan : undefined);
+ const replacementSpan = entry.replacementSpan || optionalReplacementSpan;
...
- if (replacementRange) {
+ if (replacementRange && features.completionInsertReplaceSupport) {
if (!insertText) {
insertText = item.label;
}
- if (features.completionInsertReplaceSupport) {
const insertRange = lsp.Range.create(replacementRange.start, position);
item.textEdit = lsp.InsertReplaceEdit.create(insertText, insertRange, replacementRange);
- } else {
- item.textEdit = lsp.TextEdit.replace(replacementRange, insertText);
- }
} else {
item.insertText = insertText;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't sound right. The replacementRange can also come from the entry.replacementSpan
itself in which case we want to create a replace TextEdit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, you are right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will try out this PR tomorrow.
Just to document that this PR addresses this comment #583 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can verify that this PR brings back the same behavior as prior to InsertReplaceSupport for servers that do not have insertReplaceSupport
.
@predragnikolic