Dart-code: Multiple `debugger();` statements in a codeblock messes up highlighting.

Created on 28 Mar 2021  路  5Comments  路  Source: Dart-Code/Dart-Code

Describe the bug
In a codeblock with multiple debugger() statements, the highlighting is inconsistent.

To Reproduce
Steps to reproduce the behavior:

  1. create the hello world app with flutter create
  2. In main.dart, replace _incrementCounter() with:
void _incrementCounter() {
    print(0);
    debugger(); //1
    print(1);
    setState(() {
    print(2);
      debugger(); //2
    print(3);
      _counter++;
    print(4);
    });
    print(5);
    debugger(); //3
    print(6);
  }
  1. Run (with or without debugging, it doesn't matter)

Expected behavior
On pressing the floating action button
Line with //1 should be highlighted first (and highlighted), followed by //2 and //3 on continuing twice respectively.

Screenshots

Ran the project(on web):

Screenshot 2021-03-28 at 6 49 42 PM

Clicked the FAB:

Screenshot 2021-03-28 at 6 49 54 PM

Pressed continue:

Screenshot 2021-03-28 at 6 50 54 PM

Pressed continue:

Screenshot 2021-03-28 at 6 51 05 PM

Versions (please complete the following information):

  • VS Code version: 1.54.3 (Universal)
  • Dart extension version: 3.20.1
  • Dart/Flutter SDK version: Channel stable, 2.0.1, on macOS 11.2.3 20D91 darwin-x64
upstream in dart / flutter

Most helpful comment

No problem, I suspected it might be web (there's a lot of complicated mapping that goes on for web). Looks like it's not DWDS, the original source map generated by ddc may be wrong, so I've filed https://github.com/dart-lang/sdk/issues/45544 about this.

All 5 comments

Turns out, that it doesn't highlight the last debugger() in the codeblock, but in the whole file!

An easy workaround is to have a non-empty when, so, for example, use debugger(when:true)

Thanks for the report! I can repro this, though only on web - so I think it may be a DWDS issue (it provides the information to understand the location of where the debugger pauses). I've filed this over at https://github.com/dart-lang/webdev/issues/1292 with some additional info from the debugger logs that will hopefully help fix. Please subscribe to that issue if you'd like updates.

Thanks!

My apologies, I should've mentioned the only web part.

No problem, I suspected it might be web (there's a lot of complicated mapping that goes on for web). Looks like it's not DWDS, the original source map generated by ddc may be wrong, so I've filed https://github.com/dart-lang/sdk/issues/45544 about this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shamrin picture shamrin  路  5Comments

mccadi picture mccadi  路  3Comments

DanTup picture DanTup  路  3Comments

FeimiSzy picture FeimiSzy  路  4Comments

ifredom picture ifredom  路  3Comments