提交 cc1e59bd 编写于 作者: M Matt Bierner

Make sure we pass through backupId in custom editors

Fixes #96484
上级 ff1b513f
......@@ -610,8 +610,9 @@ namespace HotExitState {
class MainThreadCustomEditorModel extends Disposable implements ICustomEditorModel, IWorkingCopy {
private _hotExitState: HotExitState.State = HotExitState.Allowed;
private readonly _fromBackup: boolean = false;
private _hotExitState: HotExitState.State = HotExitState.Allowed;
private _backupId: string | undefined;
private _currentEditIndex: number = -1;
private _savePoint: number = -1;
......@@ -716,6 +717,10 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
return this._viewType;
}
public get backupId() {
return this._backupId;
}
public pushEdit(editId: number, label: string | undefined) {
if (!this._editable) {
throw new Error('Document is not editable');
......@@ -902,6 +907,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
if (this._hotExitState === pendingState) {
this._hotExitState = HotExitState.Allowed;
backupData.meta!.backupId = backupId;
this._backupId = backupId;
}
} catch (e) {
// Make sure state has not changed in the meantime
......
......@@ -29,7 +29,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
private readonly _editorResource: URI;
private _defaultDirtyState: boolean | undefined;
public readonly backupId: string | undefined;
private readonly _backupId: string | undefined;
get resource() { return this._editorResource; }
......@@ -54,7 +54,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
super(id, viewType, '', webview, webviewService, webviewWorkbenchService);
this._editorResource = resource;
this._defaultDirtyState = options.startsDirty;
this.backupId = options.backupId;
this._backupId = options.backupId;
}
public getTypeId(): string {
......@@ -213,7 +213,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
this.viewType,
this.id,
new Lazy(() => undefined!),
{ startsDirty: this._defaultDirtyState, backupId: this.backupId }); // this webview is replaced in the transfer call
{ startsDirty: this._defaultDirtyState, backupId: this._backupId }); // this webview is replaced in the transfer call
this.transfer(newEditor);
newEditor.updateGroup(group);
return newEditor;
......@@ -245,4 +245,11 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
this._moveHandler = undefined;
return other;
}
get backupId(): string | undefined {
if (this._modelRef) {
return this._modelRef.object.backupId;
}
return this._backupId;
}
}
......@@ -56,6 +56,7 @@ export interface ICustomEditorModelManager {
export interface ICustomEditorModel extends IDisposable {
readonly viewType: string;
readonly resource: URI;
readonly backupId: string | undefined;
isReadonly(): boolean;
......
......@@ -54,6 +54,10 @@ export class CustomTextEditorModel extends Disposable implements ICustomEditorMo
return this._model.object.isReadonly();
}
public get backupId() {
return undefined;
}
public isDirty(): boolean {
return this.textFileService.isDirty(this.resource);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册