mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52: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 ------
|
||||
|
||||
interface MyCompletionItem extends monaco.languages.CompletionItem {
|
||||
label: string;
|
||||
uri: Uri;
|
||||
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 {
|
||||
const edits: monaco.languages.ResourceTextEdit[] = codeFix.changes.map(edit => ({
|
||||
resource: model.uri,
|
||||
edits: edit.textChanges.map(tc => ({
|
||||
range: this._textSpanToRange(model, tc.span),
|
||||
text: tc.newText
|
||||
}))
|
||||
}));
|
||||
const edits: monaco.languages.WorkspaceTextEdit[] = [];
|
||||
for (const change of codeFix.changes) {
|
||||
for (const textChange of change.textChanges) {
|
||||
edits.push({
|
||||
resource: model.uri,
|
||||
edit: {
|
||||
range: this._textSpanToRange(model, textChange.span),
|
||||
text: textChange.newText
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const action: monaco.languages.CodeAction = {
|
||||
title: codeFix.description,
|
||||
|
|
@ -763,22 +769,14 @@ export class RenameAdapter extends Adapter implements monaco.languages.RenamePro
|
|||
return;
|
||||
}
|
||||
|
||||
const fileNameToResourceTextEditMap: { [fileName: string]: monaco.languages.ResourceTextEdit } = {};
|
||||
|
||||
const edits: monaco.languages.ResourceTextEdit[] = [];
|
||||
const edits: monaco.languages.WorkspaceTextEdit[] = [];
|
||||
for (const renameLocation of renameLocations) {
|
||||
if (!(renameLocation.fileName in fileNameToResourceTextEditMap)) {
|
||||
const resourceTextEdit = {
|
||||
edits: [],
|
||||
resource: monaco.Uri.parse(renameLocation.fileName)
|
||||
};
|
||||
fileNameToResourceTextEditMap[renameLocation.fileName] = resourceTextEdit;
|
||||
edits.push(resourceTextEdit);
|
||||
}
|
||||
|
||||
fileNameToResourceTextEditMap[renameLocation.fileName].edits.push({
|
||||
range: this._textSpanToRange(model, renameLocation.textSpan),
|
||||
text: newName
|
||||
edits.push({
|
||||
resource: monaco.Uri.parse(renameLocation.fileName),
|
||||
edit: {
|
||||
range: this._textSpanToRange(model, renameLocation.textSpan),
|
||||
text: newName
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue