Path: blob/main/src/vs/workbench/common/editor/editorModel.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Emitter } from '../../../base/common/event.js';6import { Disposable } from '../../../base/common/lifecycle.js';78/**9* The editor model is the heavyweight counterpart of editor input. Depending on the editor input, it10* resolves from a file system retrieve content and may allow for saving it back or reverting it.11* Editor models are typically cached for some while because they are expensive to construct.12*/13export class EditorModel extends Disposable {1415private readonly _onWillDispose = this._register(new Emitter<void>());16readonly onWillDispose = this._onWillDispose.event;1718private resolved = false;1920/**21* Causes this model to resolve returning a promise when loading is completed.22*/23async resolve(): Promise<void> {24this.resolved = true;25}2627/**28* Returns whether this model was loaded or not.29*/30isResolved(): boolean {31return this.resolved;32}3334/**35* Find out if this model has been disposed.36*/37isDisposed(): boolean {38return this._store.isDisposed;39}4041/**42* Subclasses should implement to free resources that have been claimed through loading.43*/44override dispose(): void {45this._onWillDispose.fire();4647super.dispose();48}49}505152