mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
improve revert logic for untitled (also dispose untitled input after save)
This commit is contained in:
@@ -58,7 +58,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
this.toUnbind.push(this.eventService.addListener2(WorkbenchEventType.UNTITLED_FILE_DELETED, (e: UntitledEditorEvent) => this.onDirtyStateChange(e)));
|
||||
this.toUnbind.push(this.eventService.addListener2(WorkbenchEventType.UNTITLED_FILE_SAVED, (e: UntitledEditorEvent) => this.onDirtyStateChange(e)));
|
||||
this.toUnbind.push(this.eventService.addListener2(WorkbenchEventType.UNTITLED_FILE_DIRTY, (e: UntitledEditorEvent) => this.onDirtyStateChange(e)));
|
||||
}
|
||||
|
||||
@@ -97,7 +97,9 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
}
|
||||
|
||||
public revert(): TPromise<boolean> {
|
||||
return this.textFileService.revert(this.resource);
|
||||
this.cachedModel.revert();
|
||||
|
||||
return TPromise.as(true);
|
||||
}
|
||||
|
||||
public suggestFileName(): string {
|
||||
@@ -179,15 +181,15 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
// Listeners
|
||||
dispose(this.toUnbind);
|
||||
|
||||
// Model
|
||||
if (this.cachedModel) {
|
||||
this.cachedModel.dispose();
|
||||
this.cachedModel = null;
|
||||
}
|
||||
|
||||
// Listeners
|
||||
dispose(this.toUnbind);
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user