mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-23 00:22:56 +01:00
Adopt editor breaking changes around WorkspaceTextEdits
This commit is contained in:
parent
dd8427dac0
commit
887411e17c
1 changed files with 20 additions and 22 deletions
|
|
@ -261,6 +261,7 @@ export class DiagnosticsAdapter extends Adapter {
|
||||||
// --- suggest ------
|
// --- suggest ------
|
||||||
|
|
||||||
interface MyCompletionItem extends monaco.languages.CompletionItem {
|
interface MyCompletionItem extends monaco.languages.CompletionItem {
|
||||||
|
label: string;
|
||||||
uri: Uri;
|
uri: Uri;
|
||||||
position: Position;
|
position: Position;
|
||||||
}
|
}
|
||||||
|
|
@ -718,13 +719,18 @@ export class CodeActionAdaptor extends FormatHelper implements monaco.languages.
|
||||||
|
|
||||||
|
|
||||||
private _tsCodeFixActionToMonacoCodeAction(model: monaco.editor.ITextModel, context: monaco.languages.CodeActionContext, codeFix: ts.CodeFixAction): monaco.languages.CodeAction {
|
private _tsCodeFixActionToMonacoCodeAction(model: monaco.editor.ITextModel, context: monaco.languages.CodeActionContext, codeFix: ts.CodeFixAction): monaco.languages.CodeAction {
|
||||||
const edits: monaco.languages.ResourceTextEdit[] = codeFix.changes.map(edit => ({
|
const edits: monaco.languages.WorkspaceTextEdit[] = [];
|
||||||
resource: model.uri,
|
for (const change of codeFix.changes) {
|
||||||
edits: edit.textChanges.map(tc => ({
|
for (const textChange of change.textChanges) {
|
||||||
range: this._textSpanToRange(model, tc.span),
|
edits.push({
|
||||||
text: tc.newText
|
resource: model.uri,
|
||||||
}))
|
edit: {
|
||||||
}));
|
range: this._textSpanToRange(model, textChange.span),
|
||||||
|
text: textChange.newText
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const action: monaco.languages.CodeAction = {
|
const action: monaco.languages.CodeAction = {
|
||||||
title: codeFix.description,
|
title: codeFix.description,
|
||||||
|
|
@ -763,22 +769,14 @@ export class RenameAdapter extends Adapter implements monaco.languages.RenamePro
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileNameToResourceTextEditMap: { [fileName: string]: monaco.languages.ResourceTextEdit } = {};
|
const edits: monaco.languages.WorkspaceTextEdit[] = [];
|
||||||
|
|
||||||
const edits: monaco.languages.ResourceTextEdit[] = [];
|
|
||||||
for (const renameLocation of renameLocations) {
|
for (const renameLocation of renameLocations) {
|
||||||
if (!(renameLocation.fileName in fileNameToResourceTextEditMap)) {
|
edits.push({
|
||||||
const resourceTextEdit = {
|
resource: monaco.Uri.parse(renameLocation.fileName),
|
||||||
edits: [],
|
edit: {
|
||||||
resource: monaco.Uri.parse(renameLocation.fileName)
|
range: this._textSpanToRange(model, renameLocation.textSpan),
|
||||||
};
|
text: newName
|
||||||
fileNameToResourceTextEditMap[renameLocation.fileName] = resourceTextEdit;
|
}
|
||||||
edits.push(resourceTextEdit);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileNameToResourceTextEditMap[renameLocation.fileName].edits.push({
|
|
||||||
range: this._textSpanToRange(model, renameLocation.textSpan),
|
|
||||||
text: newName
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue