Skip to content

Commit bbfb239

Browse files
authored
Fixes bugs #11777 and #11726, 'outputPrepend' needed to be cleared on each cell execute. (#11871)
* Fixes bugs #11777 and #11726 Changed 'outputPrepend' to be a per 'execution' tag instead of a per 'session' tag. Once it got saved in the ipynb file, it never went away, thus always showing the truncation message. All fixed an egregious spelling error. * Fixes bugs #11777 and #11726 Changed 'outputPrepend' to be a per 'execution' tag instead of a per 'session' tag. Once it got saved in the ipynb file, it never went away, thus always showing the truncation message. All fixed an egregious spelling error.
1 parent 1fcb309 commit bbfb239

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/client/datascience/interactive-ipynb/nativeEditor.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,11 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
589589
// Clear the result if we've run before
590590
await this.clearResult(cell.id);
591591

592+
// Clear 'per run' data passed to WebView before execution
593+
if (cell.data.metadata.tags !== undefined) {
594+
cell.data.metadata.tags = cell.data.metadata.tags.filter((t) => t !== 'outputPrepend');
595+
}
596+
592597
const code = concatMultilineStringInput(cell.data.source);
593598
// Send to ourselves.
594599
await this.submitCode(code, Identifiers.EmptyFileName, 0, cell.id, cell.data, undefined, cancelToken);

src/client/datascience/jupyter/jupyterNotebook.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,8 +1283,8 @@ export class JupyterNotebookBase implements INotebook {
12831283
trimFunc: (str: string) => string
12841284
) {
12851285
const data: nbformat.ICodeCell = cell.data as nbformat.ICodeCell;
1286-
let originalTextLenght = 0;
1287-
let trimmedTextLenght = 0;
1286+
let originalTextLength = 0;
1287+
let trimmedTextLength = 0;
12881288

12891289
// Clear output if waiting for a clear
12901290
if (clearState.value) {
@@ -1301,32 +1301,36 @@ export class JupyterNotebookBase implements INotebook {
13011301
// tslint:disable-next-line:restrict-plus-operands
13021302
existing.text = existing.text + msg.content.text;
13031303
const originalText = formatStreamText(concatMultilineStringOutput(existing.text));
1304-
originalTextLenght = originalText.length;
1304+
originalTextLength = originalText.length;
13051305
existing.text = trimFunc(originalText);
1306-
trimmedTextLenght = existing.text.length;
1306+
trimmedTextLength = existing.text.length;
13071307
} else {
13081308
const originalText = formatStreamText(concatMultilineStringOutput(msg.content.text));
1309-
originalTextLenght = originalText.length;
1309+
originalTextLength = originalText.length;
13101310
// Create a new stream entry
13111311
const output: nbformat.IStream = {
13121312
output_type: 'stream',
13131313
name: msg.content.name,
13141314
text: trimFunc(originalText)
13151315
};
13161316
data.outputs = [...data.outputs, output];
1317-
trimmedTextLenght = output.text.length;
1317+
trimmedTextLength = output.text.length;
13181318
cell.data = data;
13191319
}
13201320

13211321
// If the output was trimmed, we add the 'outputPrepend' metadata tag.
13221322
// Later, the react side will display a message letting the user know
13231323
// the output is trimmed and what setting changes that.
1324-
if (trimmedTextLenght < originalTextLenght) {
1325-
if (!data.metadata.tags) {
1326-
data.metadata.tags = ['outputPrepend'];
1327-
} else {
1328-
data.metadata.tags.push('outputPrepend');
1329-
}
1324+
// * If data.metadata.tags is undefined, define it so the following
1325+
// code is can rely on it being defined.
1326+
if (data.metadata.tags === undefined) {
1327+
data.metadata.tags = [];
1328+
}
1329+
1330+
data.metadata.tags = data.metadata.tags.filter((t) => t !== 'outputPrepend');
1331+
1332+
if (trimmedTextLength < originalTextLength) {
1333+
data.metadata.tags.push('outputPrepend');
13301334
}
13311335
}
13321336

src/datascience-ui/interactive-common/kernelSelection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export class KernelSelection extends React.Component<IKernelSelectionProps> {
9696
: ImageName.JupyterServerConnected;
9797
}
9898

99-
private getMaxWidth(charLenght: number): string {
99+
private getMaxWidth(charLength: number): string {
100100
// This comes from a linear regression
101-
const width = 0.57674 * charLenght + 1.70473;
101+
const width = 0.57674 * charLength + 1.70473;
102102
const unit = 'em';
103103
return Math.round(width).toString() + unit;
104104
}

0 commit comments

Comments
 (0)