Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/7483.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Perf improvements for opening notebooks with more than 100 cells.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.datascience-ui.dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"escape-carriage",
"extend",
"fast-plist",
"immutable",
"inherits",
"is-alphabetical",
"is-alphanumerical",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@
},
"python.dataScience.useNotebookEditor": {
"type": "boolean",
"default": false,
"default": true,
"description": "Automatically open .ipynb files in the Notebook Editor.",
"scope": "resource"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,21 @@ import { IFileSystem, TemporaryFile } from '../../../common/platform/types';
import { createDeferred, Deferred, waitForPromise } from '../../../common/utils/async';
import { concatMultilineString } from '../../common';
import { Identifiers, Settings } from '../../constants';
import {
IInteractiveWindowInfo,
IInteractiveWindowListener,
IInteractiveWindowProvider,
IJupyterExecution,
INotebook
} from '../../types';
import { IInteractiveWindowListener, IInteractiveWindowProvider, IJupyterExecution, INotebook } from '../../types';
import {
IAddCell,
ICancelIntellisenseRequest,
IEditCell,
IInsertCell,
IInteractiveWindowMapping,
ILoadAllCells,
INotebookIdentity,
InteractiveWindowMessages,
IProvideCompletionItemsRequest,
IProvideHoverRequest,
IProvideSignatureHelpRequest,
IRemoveCell
IRemoveCell,
ISwapCells
} from '../interactiveWindowTypes';
import { convertStringsToSuggestions } from './conversion';
import { IntellisenseDocument } from './intellisenseDocument';
Expand Down Expand Up @@ -110,10 +106,18 @@ export abstract class BaseIntellisenseProvider implements IInteractiveWindowList
this.dispatchMessage(message, payload, this.addCell);
break;

case InteractiveWindowMessages.InsertCell:
this.dispatchMessage(message, payload, this.insertCell);
break;

case InteractiveWindowMessages.RemoveCell:
this.dispatchMessage(message, payload, this.removeCell);
break;

case InteractiveWindowMessages.SwapCells:
this.dispatchMessage(message, payload, this.swapCells);
break;

case InteractiveWindowMessages.DeleteAllCells:
this.dispatchMessage(message, payload, this.removeAllCells);
break;
Expand All @@ -130,10 +134,6 @@ export abstract class BaseIntellisenseProvider implements IInteractiveWindowList
this.dispatchMessage(message, payload, this.loadAllCells);
break;

case InteractiveWindowMessages.SendInfo:
this.dispatchMessage(message, payload, this.handleNativeEditorChanges);
break;

default:
break;
}
Expand Down Expand Up @@ -337,6 +337,15 @@ export abstract class BaseIntellisenseProvider implements IInteractiveWindowList
}
}

private async insertCell(request: IInsertCell): Promise<void> {
// Get the document and then pass onto the sub class
const document = await this.getDocument();
if (document) {
const changes = document.insertCell(request.id, request.code, request.codeCellAbove);
return this.handleChanges(undefined, document, changes);
}
}

private async editCell(request: IEditCell): Promise<void> {
// First get the document
const document = await this.getDocument();
Expand All @@ -346,47 +355,45 @@ export abstract class BaseIntellisenseProvider implements IInteractiveWindowList
}
}

private removeCell(_request: IRemoveCell): Promise<void> {
// Skip this request. The logic here being that
// a user can remove a cell from the UI, but it's still loaded into the Jupyter kernel.
return Promise.resolve();
private async removeCell(request: IRemoveCell): Promise<void> {
// First get the document
const document = await this.getDocument();
if (document) {
const changes = document.remove(request.id);
return this.handleChanges(undefined, document, changes);
}
}

private removeAllCells(): Promise<void> {
// Skip this request. The logic here being that
// a user can remove a cell from the UI, but it's still loaded into the Jupyter kernel.
return Promise.resolve();
private async swapCells(request: ISwapCells): Promise<void> {
// First get the document
const document = await this.getDocument();
if (document) {
const changes = document.swap(request.firstCellId, request.secondCellId);
return this.handleChanges(undefined, document, changes);
}
}

private async loadAllCells(payload: ILoadAllCells) {
private async removeAllCells(): Promise<void> {
// First get the document
const document = await this.getDocument();
if (document) {
document.switchToEditMode();
await Promise.all(payload.cells.map(async cell => {
if (cell.data.cell_type === 'code') {
const text = concatMultilineString(cell.data.source);
const addCell: IAddCell = {
fullText: text,
currentText: text,
file: cell.file,
id: cell.id
};
await this.addCell(addCell);
}
}));
const changes = document.removeAll();
return this.handleChanges(undefined, document, changes);
}
}

private async handleNativeEditorChanges(payload: IInteractiveWindowInfo) {
private async loadAllCells(payload: ILoadAllCells) {
const document = await this.getDocument();
let changes: TextDocumentContentChangeEvent[][] = [];
const file = payload.visibleCells[0] ? payload.visibleCells[0].file : undefined;

if (document) {
changes = document.handleNativeEditorCellChanges(payload.visibleCells);
}
const changes = document.loadAllCells(payload.cells.filter(c => c.data.cell_type === 'code').map(cell => {
return {
code: concatMultilineString(cell.data.source),
id: cell.id
};
}));

await Promise.all(changes.map(c => this.handleChanges(file, document, c)));
await this.handleChanges(Identifiers.EmptyFileName, document, changes);
}
}

private async restartKernel(): Promise<void> {
Expand Down
Loading