Skip to content

Commit 724217d

Browse files
author
Benjamin Pasero
committed
console - restore findFirstFrame
1 parent fc531c6 commit 724217d

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/vs/base/node/console.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function getFirstFrame(arg0: IRemoteConsoleLog | string): IStackFrame {
6969
// at e.$executeContributedCommand(c:\Users\someone\Desktop\end-js\extension.js:19:17)
7070
const stack = arg0;
7171
if (stack) {
72-
const topFrame = stack.split('\n')[0];
72+
const topFrame = findFirstFrame(stack);
7373

7474
// at [^\/]* => line starts with "at" followed by any character except '/' (to not capture unix paths too late)
7575
// (?:(?:[a-zA-Z]+:)|(?:[\/])|(?:\\\\) => windows drive letter OR unix root OR unc root
@@ -88,12 +88,25 @@ export function getFirstFrame(arg0: IRemoteConsoleLog | string): IStackFrame {
8888
return void 0;
8989
}
9090

91+
function findFirstFrame(stack: string): string {
92+
if (!stack) {
93+
return stack;
94+
}
95+
96+
const newlineIndex = stack.indexOf('\n');
97+
if (newlineIndex === -1) {
98+
return stack;
99+
}
100+
101+
return stack.substring(0, newlineIndex);
102+
}
103+
91104
export function log(entry: IRemoteConsoleLog, label: string): void {
92105
const { args, stack } = parse(entry);
93106

94107
const isOneStringArg = typeof args[0] === 'string' && args.length === 1;
95108

96-
let topFrame = stack && stack.split('\n')[0];
109+
let topFrame = findFirstFrame(stack);
97110
if (topFrame) {
98111
topFrame = `(${topFrame.trim()})`;
99112
}

0 commit comments

Comments
 (0)