Skip to content

Commit 275b0d9

Browse files
authored
fix: DH-13244: remove trailing whitespace from console log messages (#2420)
Cherry pick from `main` https://deephaven.atlassian.net/browse/DH-13244 There was a fix for single line console messages here: #350 However, this fix did not account for trailing newline characters in the message. This fix trims whitespace from the end of the message.
1 parent 8bb2c71 commit 275b0d9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/console/src/console-history/ConsoleHistoryResultErrorMessage.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,15 @@ class ConsoleHistoryResultErrorMessage extends PureComponent<
121121
const { isExpanded, isTriggerHovered } = this.state;
122122
const { message: messageProp } = this.props;
123123
assertNotNull(messageProp);
124-
const lineBreakIndex = messageProp.indexOf('\n');
124+
// Trim trailing whitespace to avoid unnecessary empty lines
125+
const message = messageProp.trimEnd();
126+
const lineBreakIndex = message.indexOf('\n');
125127
const isMultiline = lineBreakIndex > -1;
126-
let topLineOfMessage = messageProp;
128+
let topLineOfMessage = message;
127129
if (isMultiline) {
128-
topLineOfMessage = messageProp.slice(0, lineBreakIndex);
130+
topLineOfMessage = message.slice(0, lineBreakIndex);
129131
}
130-
const remainderOfMessage = messageProp.slice(lineBreakIndex);
132+
const remainderOfMessage = message.slice(lineBreakIndex);
131133
const arrowBtnClasses = isTriggerHovered
132134
? 'error-btn-link error-btn-link--active'
133135
: 'error-btn-link';

0 commit comments

Comments
 (0)