-
Notifications
You must be signed in to change notification settings - Fork 0
Rebornix/fashionable primate #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
eb948e1
366df5a
c363def
e3caeae
12abccc
eccf86a
b6669a7
cdc45ff
f7e0eab
65f36ea
fc8fda5
f9adfe4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { notebookSerializationWorkerData } from './common'; | ||
| import { workerData, parentPort } from 'node:worker_threads'; | ||
|
|
||
| function sortObjectPropertiesRecursively(obj: any): any { | ||
| if (Array.isArray(obj)) { | ||
| return obj.map(sortObjectPropertiesRecursively); | ||
| } | ||
| if (obj !== undefined && obj !== null && typeof obj === 'object' && Object.keys(obj).length > 0) { | ||
| return ( | ||
| Object.keys(obj) | ||
| .sort() | ||
| .reduce<Record<string, any>>((sortedObj, prop) => { | ||
| sortedObj[prop] = sortObjectPropertiesRecursively(obj[prop]); | ||
| return sortedObj; | ||
| }, {}) as any | ||
| ); | ||
| } | ||
| return obj; | ||
| } | ||
|
|
||
| if (parentPort) { | ||
| const { notebookContent, indentAmount } = <notebookSerializationWorkerData>workerData; | ||
| const json = JSON.stringify(sortObjectPropertiesRecursively(notebookContent), undefined, indentAmount) + '\n'; | ||
| parentPort.postMessage(json); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,7 +105,17 @@ export class CellEditorStatusBar extends CellContentPart { | |
| event: e | ||
| }); | ||
| } else { | ||
| if ((e.target as HTMLElement).classList.contains('cell-status-item-has-command')) { | ||
| const target = e.target; | ||
| let itemHasCommand = false; | ||
| if (target && DOM.isHTMLElement(target)) { | ||
| const targetElement = <HTMLElement>target; | ||
| if (targetElement.classList.contains('cell-status-item-has-command')) { | ||
| itemHasCommand = true; | ||
| } else if (targetElement.parentElement && targetElement.parentElement.classList.contains('cell-status-item-has-command')) { | ||
| itemHasCommand = true; | ||
| } | ||
| } | ||
| if (itemHasCommand) { | ||
|
Comment on lines
+108
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Approved: Enhanced Command Detection Logic The updated logic for detecting command-associated elements in the status bar is more robust, checking both the target and its parent. This change improves the accuracy and reliability of command detection, which is crucial for user interactions in the notebook environment. Consider adding unit tests to ensure this new logic works as expected across different scenarios. Would you like me to help with writing the unit tests for this new logic? |
||
| this._onDidClick.fire({ | ||
| type: ClickTargetType.ContributedCommandItem, | ||
| event: e | ||
|
|
||
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.
Refactor Suggestion: Simplify Serialization Logic
The method
serializeNotebookToJSONeffectively handles conditional serialization logic based on the environment and configuration. However, consider simplifying the conditional branches to enhance readability and maintainability.Here's a suggested refactor:
Committable suggestion