-
Notifications
You must be signed in to change notification settings - Fork 35.4k
notebook diff editor perf improvement #112176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few points - mostly suggestions on removing duplication and improving readability. One question I cannot answer is do these changes require and changes to existing unit tests?
private _maxComputationTime: number; | ||
private _renderIndicators: boolean; | ||
private _enableSplitViewResizing: boolean; | ||
private _wordWrap: 'off' | 'on' | 'wordWrapColumn' | 'bounded' | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would make sense to be of type enum
enum wordWrapEnum {
Off,
On,
WordWrapColumn,
Bounded
};
private _wordWrap: wordWrapEnum | null;
private _enableSplitViewResizing: boolean; | ||
private _wordWrap: 'off' | 'on' | 'wordWrapColumn' | 'bounded' | undefined; | ||
private _wordWrapMinified: boolean | undefined; | ||
private _renderOverviewRuler: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As stated above these are not used? Is this intended?
this._contextKeyService.createKey('isInEmbeddedDiffEditor', false); | ||
} | ||
|
||
this._renderOverviewRuler = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could roll this up into one-linear
this._renderOverviewRuler = typeof options.renderOverviewRuler !== 'undefined' ? Boolean(options.renderOverviewRuler) : true;
this._isHandlingScrollEvent = false; | ||
|
||
this._elementSizeObserver = this._register(new ElementSizeObserver(this._containerDomElement, undefined, () => this._onDidContainerSizeChanged())); | ||
this._elementSizeObserver = this._register(new ElementSizeObserver(this._containerDomElement, options.dimension, () => this._onDidContainerSizeChanged())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit-pick: arrow function not required:
this._elementSizeObserver = this._register(new ElementSizeObserver(this._containerDomElement, options.dimension, this._onDidContainerSizeChanged);
result.scrollbar!.verticalHasArrows = false; | ||
result.extraEditorClassName = 'modified-in-monaco-diff-editor'; | ||
return result; | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate of lines 1156 - 1162. One could add a private helper function e.g.
function addDimension(result) : editorBrowser.IEditorConstructionOptions {
return {
...result,
dimension: {
height: 0,
width: 0
}
};
Then call the helper from both places e.g.
return addDimension(result);
*/ | ||
isInEmbeddedEditor?: boolean; | ||
/** | ||
* Is the diff editor should render overview ruler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a typo here: Is vs If?
readonly notebookEditor: INotebookTextDiffEditor, | ||
readonly cell: CellDiffViewModel, | ||
readonly templateData: CellDiffSingleSideRenderTemplate, | ||
readonly style: 'left' | 'right' | 'full', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be an enum?
enum styleAlignments {
Left,
Right,
Full
};
this._register(this._editor); | ||
this._editor = this.templateData.sourceEditor; | ||
this._editor.layout({ | ||
width: (this.notebookEditor.getLayoutInfo().width - 2 * DIFF_CELL_MARGIN) / 2 - 18, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 18 is a magic number. A named constant would help understand what this is for. That said, as if is a copy-paste then we can just skip adding the constant if you do not know.
buildBody() { | ||
const body = this.templateData.body; | ||
this._diffEditorContainer = this.templateData.diffEditorContainer; | ||
switch (this.style) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This switch statement duplicated above. We could move this into a new function on the shared parent abstraction can call it from both places?
This PR fixes #109680. It consists of following major changes:
The diff editor is slower than the native notebook editor, simply because in the diff editor, the amount of monaco editors doubled. The creation and deletion of monaco editors has some cost, even if it's a few miliseconds, rendering 20 monaco editors in a large viewport can cost ~100ms. So the performance of scrolling in the diff editor is definitely slower than scrolling in a notebook editor with the same resource.