Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async logOutput(session: DebugSession, event: DebugProtocol.OutputEvent): Promise {
const body = event.body;
const { category, variablesReference } = body;
if (category === 'telemetry') {
console.debug(`telemetry/${event.body.output}`, event.body.data);
return;
}
const severity = category === 'stderr' ? Severity.Error : event.body.category === 'console' ? Severity.Warning : Severity.Info;
if (variablesReference) {
const items = await new ExpressionContainer({ session, variablesReference }).getElements();
this.items.push(...items);
} else if (typeof body.output === 'string') {
for (const line of body.output.split('\n')) {
this.items.push(new AnsiConsoleItem(line, severity));
}
}
this.fireDidChange();
}
appendLine(value: string): void {
this.items.push(new AnsiConsoleItem(value, Severity.Info));
this.fireDidChange();
}
append(value: string): void {
if (!value) {
return;
}
const lastItem = this.items.slice(-1)[0];
if (lastItem instanceof AnsiConsoleItem && lastItem.content === this.uncompletedItemContent) {
this.items.pop();
this.uncompletedItemContent += value;
} else {
this.uncompletedItemContent = value;
}
this.items.push(new AnsiConsoleItem(this.uncompletedItemContent, Severity.Info));
this.fireDidChange();
}