提交 1c9015ae 编写于 作者: B Benjamin Pasero

types 💄

上级 3c6f6af7
......@@ -416,18 +416,20 @@ export interface IEditorInput extends IDisposable {
* to e.g. preserve view state of the editor and re-open it
* in the correct group after saving.
*
* @returns the resulting editor input of this operation. Can
* be the same editor input.
* @returns the resulting editor input (typically the same) of
* this operation or `undefined` to indicate that the operation
* failed or was canceled.
*/
save(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined>;
/**
* Saves the editor to a different location. The provided groupId
* Saves the editor to a different location. The provided `group`
* helps implementors to e.g. preserve view state of the editor
* and re-open it in the correct group after saving.
*
* @returns the resulting editor input of this operation. Typically
* a different editor input.
* @returns the resulting editor input (typically a different one)
* of this operation or `undefined` to indicate that the operation
* failed or was canceled.
*/
saveAs(group: GroupIdentifier, options?: ISaveOptions): Promise<IEditorInput | undefined>;
......
......@@ -17,7 +17,7 @@ export class DiffEditorInput extends SideBySideEditorInput {
static readonly ID = 'workbench.editors.diffEditorInput';
private cachedModel: DiffEditorModel | null = null;
private cachedModel: DiffEditorModel | undefined = undefined;
constructor(
protected name: string | undefined,
......@@ -96,7 +96,7 @@ export class DiffEditorInput extends SideBySideEditorInput {
// them without sideeffects.
if (this.cachedModel) {
this.cachedModel.dispose();
this.cachedModel = null;
this.cachedModel = undefined;
}
super.dispose();
......
......@@ -21,8 +21,8 @@ export class ResourceEditorInput extends TextEditorInput implements IModeSupport
static readonly ID: string = 'workbench.editors.resourceEditorInput';
private cachedModel: ResourceEditorModel | null = null;
private modelReference: Promise<IReference<ITextEditorModel>> | null = null;
private cachedModel: ResourceEditorModel | undefined = undefined;
private modelReference: Promise<IReference<ITextEditorModel>> | undefined = undefined;
constructor(
private name: string | undefined,
......@@ -91,7 +91,7 @@ export class ResourceEditorInput extends TextEditorInput implements IModeSupport
// Ensure the resolved model is of expected type
if (!(model instanceof ResourceEditorModel)) {
ref.dispose();
this.modelReference = null;
this.modelReference = undefined;
throw new Error(`Unexpected model for ResourceInput: ${this.resource}`);
}
......@@ -122,10 +122,10 @@ export class ResourceEditorInput extends TextEditorInput implements IModeSupport
dispose(): void {
if (this.modelReference) {
this.modelReference.then(ref => ref.dispose());
this.modelReference = null;
this.modelReference = undefined;
}
this.cachedModel = null;
this.cachedModel = undefined;
super.dispose();
}
......
......@@ -28,9 +28,9 @@ export class UntitledTextEditorInput extends TextEditorInput implements IEncodin
private readonly _onDidModelChangeEncoding = this._register(new Emitter<void>());
readonly onDidModelChangeEncoding = this._onDidModelChangeEncoding.event;
private cachedModel: UntitledTextEditorModel | null = null;
private cachedModel: UntitledTextEditorModel | undefined = undefined;
private modelResolve: Promise<UntitledTextEditorModel & IResolvedTextEditorModel> | null = null;
private modelResolve: Promise<UntitledTextEditorModel & IResolvedTextEditorModel> | undefined = undefined;
private preferredMode: string | undefined;
......@@ -255,8 +255,8 @@ export class UntitledTextEditorInput extends TextEditorInput implements IEncodin
}
dispose(): void {
this.cachedModel = null;
this.modelResolve = null;
this.cachedModel = undefined;
this.modelResolve = undefined;
super.dispose();
}
......
......@@ -139,7 +139,7 @@ export class TextModelResolverService implements ITextModelService {
private async doCreateModelReference(resource: URI): Promise<IReference<IResolvedTextEditorModel>> {
// Untitled Schema: go through cached input
// Untitled Schema: go through untitled text service
if (resource.scheme === network.Schemas.untitled) {
const model = await this.untitledTextEditorService.resolve({ untitledResource: resource });
......@@ -149,7 +149,6 @@ export class TextModelResolverService implements ITextModelService {
// InMemory Schema: go through model service cache
if (resource.scheme === network.Schemas.inMemory) {
const cachedModel = this.modelService.getModel(resource);
if (!cachedModel) {
throw new Error('Cant resolve inmemory resource');
}
......
......@@ -140,7 +140,7 @@ export class UntitledTextEditorService extends Disposable implements IUntitledTe
private readonly _onDidChangeLabel = this._register(new Emitter<URI>());
readonly onDidChangeLabel = this._onDidChangeLabel.event;
protected readonly mapResourceToInput = new ResourceMap<UntitledTextEditorInput>();
private readonly mapResourceToInput = new ResourceMap<UntitledTextEditorInput>();
private readonly mapResourceToAssociatedFilePath = new ResourceMap<boolean>();
constructor(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册