Adopt latest editor, latest language service

This commit is contained in:
Alex Dima 2020-09-19 01:49:24 +02:00
parent be0f95eaff
commit 928e5ba14e
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
3 changed files with 73 additions and 42 deletions

View file

@ -192,6 +192,30 @@ function toRange(range: jsonService.Range): Range {
);
}
interface InsertReplaceEdit {
/**
* The string to be inserted.
*/
newText: string;
/**
* The range if the insert is requested
*/
insert: jsonService.Range;
/**
* The range if the replace is requested.
*/
replace: jsonService.Range;
}
function isInsertReplaceEdit(
edit: jsonService.TextEdit | InsertReplaceEdit
): edit is InsertReplaceEdit {
return (
typeof (<InsertReplaceEdit>edit).insert !== 'undefined' &&
typeof (<InsertReplaceEdit>edit).replace !== 'undefined'
);
}
function toCompletionItemKind(kind: number): languages.CompletionItemKind {
let mItemKind = languages.CompletionItemKind;
@ -337,7 +361,14 @@ export class CompletionAdapter implements languages.CompletionItemProvider {
kind: toCompletionItemKind(entry.kind)
};
if (entry.textEdit) {
item.range = toRange(entry.textEdit.range);
if (isInsertReplaceEdit(entry.textEdit)) {
item.range = {
insert: toRange(entry.textEdit.insert),
replace: toRange(entry.textEdit.replace)
};
} else {
item.range = toRange(entry.textEdit.range);
}
item.insertText = entry.textEdit.newText;
}
if (entry.additionalTextEdits) {