Fix an off-by-one bug between stack_trace and source_maps. R=kevmoo@google.com Review URL: https://codereview.chromium.org//1113453006
diff --git a/CHANGELOG.md b/CHANGELOG.md index b13f72f..81f21e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -1,3 +1,7 @@ +## 1.0.2 + +* Fix an off-by-one bug that was causing line numbers to be slightly off. + ## 1.0.1 * Don't crash when mapping stack chains.
diff --git a/lib/source_map_stack_trace.dart b/lib/source_map_stack_trace.dart index a5a22b3..41072e4 100644 --- a/lib/source_map_stack_trace.dart +++ b/lib/source_map_stack_trace.dart
@@ -51,7 +51,10 @@ // If there's no column, try using the first column of the line. var column = frame.column == null ? 0 : frame.column; - var span = sourceMap.spanFor(frame.line, column); + + // Subtract 1 because stack traces use 1-indexed lines and columns and + // source maps uses 0-indexed. + var span = sourceMap.spanFor(frame.line - 1, column - 1); // If we can't find a source span, ignore the frame. It's probably something // internal that the user doesn't care about.
diff --git a/pubspec.yaml b/pubspec.yaml index afa10ad..a44df62 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,5 +1,5 @@ name: source_map_stack_trace -version: 1.0.1 +version: 1.0.2 description: > A package for applying source maps to stack traces. author: Dart Team <misc@dartlang.org>