Skip to content

Conversation

DonJayamanne
Copy link
Contributor

This PR fixes #129370

@@ -61,8 +69,19 @@ function sortOutputItemsBasedOnDisplayOrder(outputItems: NotebookCellOutputItem[
}
return compareWith.startsWith(value);
};
const indexOfMimeTypeA = orderOfMimeTypes.findIndex(mime => isMimeTypeMatch(outputItemA.mime, mime));
const indexOfMimeTypeB = orderOfMimeTypes.findIndex(mime => isMimeTypeMatch(outputItemB.mime, mime));
let indexOfMimeTypeA = orderOfMimeTypes.findIndex((mime) => isMimeTypeMatch(mime, outputItemA.mime));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added something that was fixed in Jupyter extension (some how this was missing here).
I've added the changes/fixes here along with the corresponding tests.

@@ -94,7 +94,7 @@ function translateCellDisplayOutput(output: NotebookCellOutput): JupyterOutput {
case 'display_data': {
result = {
output_type: 'display_data',
data: output.items.reduceRight((prev: any, curr) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it was reduceRight, it should be reduce (fix everywhere else)

.reduceRight<string[]>((prev, curr) => prev.concat(curr), []);
.forEach(value => {
// Ensure each line is a seprate entry in an array (ending with \n).
const lines = value.split('\n');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes as per the comments here #129370 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the split, we do want to handle CRLF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to (this is how we used to do it & based on what I know this is what Jupyter also does, - code was borrowed from Jupyter)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rchiodo /cc


suite('Output Order', () => {
test('Verify order of outputs', async () => {
const dataAndExpectedOrder: { output: nbformat.IDisplayData; expectedMimeTypesOrder: string[] }[] = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests for a fix that was missing

@DonJayamanne DonJayamanne marked this pull request as ready for review August 17, 2021 19:56
@TylerLeonhardt TylerLeonhardt removed their assignment Aug 17, 2021
@DonJayamanne DonJayamanne requested a review from rchiodo August 17, 2021 21:53
Copy link
Member

@rebornix rebornix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 for the multi line stream improvement, only a few suggestions of how to improve the sorting.

Regarding indentation detection, I like that we can drop the external dependency but not sure how confident we are with the behavior change.

.reduceRight<string[]>((prev, curr) => prev.concat(curr), []);
.forEach(value => {
// Ensure each line is a seprate entry in an array (ending with \n).
const lines = value.split('\n');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the split, we do want to handle CRLF?

Copy link
Member

@rebornix rebornix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great! 🚢

@DonJayamanne DonJayamanne merged commit b23486e into microsoft:main Aug 24, 2021
@DonJayamanne DonJayamanne deleted the issue129370 branch August 24, 2021 20:51
DonJayamanne added a commit that referenced this pull request Aug 24, 2021
This reverts commit b23486e, reversing
changes made to 9e07323.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid unnecessary string join and split
5 participants