mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Adopt latest editor, latest language service
This commit is contained in:
parent
be0f95eaff
commit
928e5ba14e
3 changed files with 73 additions and 42 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue