Do not hard-code Typing as the label for SingleModelEditStackElement

This commit is contained in:
Alex Dima 2022-03-14 14:41:54 +01:00
parent 780cd3096b
commit 6e0be36443
No known key found for this signature in database
GPG key ID: 39563C1504FDD0C9
2 changed files with 8 additions and 8 deletions

View file

@ -161,11 +161,11 @@ export class SingleModelEditStackElement implements IResourceUndoRedoElement {
return this.model.uri;
}
public get label(): string {
return nls.localize('edit', "Typing");
}
constructor(model: ITextModel, beforeCursorState: Selection[] | null) {
constructor(
public readonly label: string,
model: ITextModel,
beforeCursorState: Selection[] | null
) {
this.model = model;
this._data = SingleModelEditStackData.create(model, beforeCursorState);
}
@ -413,7 +413,7 @@ export class EditStack {
if (isEditStackElement(lastElement) && lastElement.canAppend(this._model)) {
return lastElement;
}
const newElement = new SingleModelEditStackElement(this._model, beforeCursorState);
const newElement = new SingleModelEditStackElement(nls.localize('edit', "Typing"), this._model, beforeCursorState);
this._undoRedoService.pushElement(newElement);
return newElement;
}

View file

@ -249,7 +249,7 @@ export class BulkTextEdits {
// This edit touches a single model => keep things simple
const task = tasks[0];
if (!task.isNoOp()) {
const singleModelEditStackElement = new SingleModelEditStackElement(task.model, task.getBeforeCursorState());
const singleModelEditStackElement = new SingleModelEditStackElement(this._label, task.model, task.getBeforeCursorState());
this._undoRedoService.pushElement(singleModelEditStackElement, this._undoRedoGroup, this._undoRedoSource);
task.apply();
singleModelEditStackElement.close();
@ -259,7 +259,7 @@ export class BulkTextEdits {
// prepare multi model undo element
const multiModelEditStackElement = new MultiModelEditStackElement(
this._label,
tasks.map(t => new SingleModelEditStackElement(t.model, t.getBeforeCursorState()))
tasks.map(t => new SingleModelEditStackElement(this._label, t.model, t.getBeforeCursorState()))
);
this._undoRedoService.pushElement(multiModelEditStackElement, this._undoRedoGroup, this._undoRedoSource);
for (const task of tasks) {