-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notebook open optimizations (#13488)
* only initialize notebbok cell editor when in viewport Signed-off-by: Jonah Iden <[email protected]> * optimzied notebook loading time by bulk creating notebook cell editor text models Signed-off-by: Jonah Iden <[email protected]> * remove measurement Signed-off-by: Jonah Iden <[email protected]> * add document for cell when creating new one Signed-off-by: Jonah Iden <[email protected]> * review changes * rebase build fixe Signed-off-by: Jonah Iden <[email protected]> * create unmaged models for monacto text model service Signed-off-by: Jonah Iden <[email protected]> --------- Signed-off-by: Jonah Iden <[email protected]>
- Loading branch information
1 parent
f41a764
commit 2c61f6c
Showing
11 changed files
with
119 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/notebook/src/browser/service/notebook-monaco-text-model-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 TypeFox and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { ReferenceCollection, URI, Reference, Event } from '@theia/core'; | ||
import { inject, injectable } from '@theia/core/shared/inversify'; | ||
import { MonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service'; | ||
import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model'; | ||
import { NotebookModel } from '../view-model/notebook-model'; | ||
|
||
/** | ||
* special service for creating monaco textmodels for notebook cells. | ||
* Its for optimization purposes since there is alot of overhead otherwise with calling the backend to create a document for each cell and other smaller things. | ||
*/ | ||
@injectable() | ||
export class NotebookMonacoTextModelService { | ||
|
||
@inject(MonacoTextModelService) | ||
protected readonly monacoTextModelService: MonacoTextModelService; | ||
|
||
protected readonly cellmodels = new ReferenceCollection<string, MonacoEditorModel>( | ||
uri => this.monacoTextModelService.createUnmangedModel(new URI(uri)) | ||
); | ||
|
||
getOrCreateNotebookCellModelReference(uri: URI): Promise<Reference<MonacoEditorModel>> { | ||
return this.cellmodels.acquire(uri.toString()); | ||
} | ||
|
||
async createTextModelsForNotebook(notebook: NotebookModel): Promise<void> { | ||
await Promise.all(notebook.cells.map(cell => this.getOrCreateNotebookCellModelReference(cell.uri))); | ||
} | ||
|
||
get onDidCreateNotebookCellModel(): Event<MonacoEditorModel> { | ||
return this.cellmodels.onDidCreate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters