Skip to content

Commit

Permalink
Fix 5144 (#9178)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchiodo authored Mar 2, 2022
1 parent b604e82 commit 1675596
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions news/3 Code Health/5144.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Eliminate unused parameter for concatMultilineString.
2 changes: 1 addition & 1 deletion src/client/datascience/jupyter/kernels/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ export function getPlainTextOrStreamOutput(outputs: nbformat.IOutput[]) {
}
if (outputs[0].output_type === 'stream') {
const stream = outputs[0] as nbformat.IStream;
return concatMultilineString(stream.text, true);
return concatMultilineString(stream.text);
}
}
return;
Expand Down
9 changes: 3 additions & 6 deletions src/datascience-ui/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { noop } from '../../client/common/utils/misc';
const SingleQuoteMultiline = "'''";
const DoubleQuoteMultiline = '"""';

export function concatMultilineString(str: nbformat.MultilineString, trim?: boolean): string {
const nonLineFeedWhiteSpaceTrim = /(^[\t\f\v\r ]+|[\t\f\v\r ]+$)/g; // Local var so don't have to reset the lastIndex.
export function concatMultilineString(str: nbformat.MultilineString): string {
if (Array.isArray(str)) {
let result = '';
for (let i = 0; i < str.length; i += 1) {
Expand All @@ -19,11 +18,9 @@ export function concatMultilineString(str: nbformat.MultilineString, trim?: bool
result = result.concat(s);
}
}

// Just trim whitespace. Leave \n in place
return trim ? result.replace(nonLineFeedWhiteSpaceTrim, '') : result;
return result;
}
return trim ? str.toString().replace(nonLineFeedWhiteSpaceTrim, '') : str.toString();
return str.toString();
}

export function splitMultilineString(source: nbformat.MultilineString): string[] {
Expand Down

0 comments on commit 1675596

Please sign in to comment.