-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fixes bugs #11777 and #11726, 'outputPrepend' needed to be cleared on each cell execute. #11871
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
Changes from 1 commit
08fb451
1811e46
fff6920
eee2590
45002a7
e95a1a8
97160bf
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 |
---|---|---|
|
@@ -1283,8 +1283,8 @@ export class JupyterNotebookBase implements INotebook { | |
trimFunc: (str: string) => string | ||
) { | ||
const data: nbformat.ICodeCell = cell.data as nbformat.ICodeCell; | ||
let originalTextLenght = 0; | ||
let trimmedTextLenght = 0; | ||
let originalTextLength = 0; | ||
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. Also not sure how this addresses https://github.com/microsoft/vscode-python/issues/11777 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. The spelling error fix is a side effect of fixing the actual bug, as in, leave the area nicer than you found it. Clearing the tag, fixes the bug. The truncating always worked, it was when the warning showed up that didn't. |
||
let trimmedTextLength = 0; | ||
|
||
// Clear output if waiting for a clear | ||
if (clearState.value) { | ||
|
@@ -1301,27 +1301,27 @@ export class JupyterNotebookBase implements INotebook { | |
// tslint:disable-next-line:restrict-plus-operands | ||
existing.text = existing.text + msg.content.text; | ||
const originalText = formatStreamText(concatMultilineStringOutput(existing.text)); | ||
originalTextLenght = originalText.length; | ||
originalTextLength = originalText.length; | ||
existing.text = trimFunc(originalText); | ||
trimmedTextLenght = existing.text.length; | ||
trimmedTextLength = existing.text.length; | ||
} else { | ||
const originalText = formatStreamText(concatMultilineStringOutput(msg.content.text)); | ||
originalTextLenght = originalText.length; | ||
originalTextLength = originalText.length; | ||
// Create a new stream entry | ||
const output: nbformat.IStream = { | ||
output_type: 'stream', | ||
name: msg.content.name, | ||
text: trimFunc(originalText) | ||
}; | ||
data.outputs = [...data.outputs, output]; | ||
trimmedTextLenght = output.text.length; | ||
trimmedTextLength = output.text.length; | ||
cell.data = data; | ||
} | ||
|
||
// If the output was trimmed, we add the 'outputPrepend' metadata tag. | ||
// Later, the react side will display a message letting the user know | ||
// the output is trimmed and what setting changes that. | ||
if (trimmedTextLenght < originalTextLenght) { | ||
if (trimmedTextLength < originalTextLength) { | ||
if (!data.metadata.tags) { | ||
data.metadata.tags = ['outputPrepend']; | ||
} else { | ||
|
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.
Thanks for submitting this PR, however I fail to see how this will solve the issue.
Doesn't this just blow away all of the tags in the metadata, meaning we're throwing away client data stored in tags.
Will wait for feedback from the rest of the team.
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.
At the moment, this is the only tag that ever gets passed over to the client. Until there is another one added, it's just a single complicated flag.
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.
Yeah this should only be clearing the flag we add. Other metadata tags may have already been there and we don't want to clear them.
In reply to: 426679031 [](ancestors = 426679031)
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.
Additionally we should not blindly push the outputPrepend tag in jupyterNotebook.ts
In reply to: 426727089 [](ancestors = 426727089,426679031)
Uh oh!
There was an error while loading. Please reload this page.
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.
Hi Barry, should have been more clear there.
cell.data.metadata.tags
can be written to by external tools (like this one https://ipypublish.readthedocs.io/en/latest/metadata_tags.html)We added the outputprepend tag, but we don't want to remove other tags that might already be there. So something like
would be better.
The real bug is that we're just blindly pushing the
outputPrepend
tag instead of doing it just once.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.
Got it. My repro case is too simplistic, as in no external tools involved. That starts to explain a lot. This is a rabbit hole :). I'll submit yet another PR.