Skip to content

debug console: collapsing identical lines breaks unless adapter sends output line-by-line #251701

Open
@HampusAdolfsson

Description

@HampusAdolfsson

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.101.0
  • OS Version: Windows 11 10.0.22631 Build 22631

The debug console's logic for collapsing identical lines actually collapses individual messages/events from the debug adapter, rather than lines. If a debug adapter emits two identical output events in sequence, they are collapsed even if there was no line break between them. Also, if a debug adapter emits a single output event containing multiple identical lines (like "hello\nhello\n"), they are not collapsed. In other words, VS Code appears to assume that the debug adapter always emits exactly one output event per line.

I'm a developer on a debug adapter for embedded devices. The I/O often runs in an unbuffered mode where output is printed to the debug console character-by-character, and this often trips up the collapsing of identical lines. For example, if the program prints a number like "55", VS Code collapses this into (2)5.

Steps to Reproduce:

  1. Add the following to the launchRequest handler of your debug adapter (e.g. the vscode-mock-debug example):
// These should print "111", but are actually collapsed
this.sendEvent(new OutputEvent("1"));
this.sendEvent(new OutputEvent("1"));
this.sendEvent(new OutputEvent("1"));
this.sendEvent(new OutputEvent("\n"));

// These should be collapsed into (2)it, but are not
this.sendEvent(new OutputEvent("it\nit\n"));
  1. Start a debug session
  2. Note the following output:

Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions