stack_trace icon indicating copy to clipboard operation
stack_trace copied to clipboard

Allow line/column numbers to be separated with colon.

Open lewisakura opened this issue 5 years ago • 1 comments

Currently, an example stack line looks like this: src\main.dart 27:15 main This looks really nice, however I would like an option for it to look like this: src\main.dart:27:15 main Note the line/column numbers are separated via : rather than a space.

The only reason I'd like it this way is because in certain terminals you can click (or CTRL+click) and it would open the file at that exact point. VSCode does this and is my primary driver, so it would make mine and possibly other people's lives easier if this was an option we could have when prettifying our stack traces.

lewisakura avatar Apr 23 '20 15:04 lewisakura

`@override
  String toString() {
    // Figure out the longest path so we know how much to pad.
    var longest =
        frames.map((frame) => frame.location.length).fold(0, math.max);

    // Print out the stack trace nicely formatted.
    return frames.map((frame) {
      if (frame is UnparsedFrame) return '$frame\n';
      final frameSplit = frame.toString().split(" ");
      final frameLocation = frameSplit[0]+":"+frameSplit[1];
      return '${frameLocation.padRight(longest)} ${frame.member}\n';
    }).join();
  }`

by editing the toString() method of Trace class i tried to resolve the issue you mentioned.

The desired output format is achieved by splitting and extracting each frame into 4 components for example:

lib/_engine/engine/platform_dispatcher.dart 269:5 in invokeOnPointerDataPacket is extracted to list of components [lib/_engine/engine/platform_dispatcher.dart, 269:5, in, invokeOnPointerDataPacket]

and then concatenating them back with : so that the output format looks like lib/_engine/engine/platform_dispatcher.dart:269:5 invokeOnPointerDataPacket

Azad99-9 avatar May 27 '23 12:05 Azad99-9