Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: lib/src/span_mixin.dart

Issue 1041163005: Support multiple occurrences of text in context (Closed) Base URL: git@github.com:dart-lang/source_span.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/span_mixin.dart
diff --git a/lib/src/span_mixin.dart b/lib/src/span_mixin.dart
index a93723f10420335257147c6b55b4808534e8d542..64c4d4847c38f6bf854a6aa4df1ed8b6f83da68a 100644
--- a/lib/src/span_mixin.dart
+++ b/lib/src/span_mixin.dart
@@ -65,11 +65,10 @@ abstract class SourceSpanMixin implements SourceSpan {
var textLine;
if (this is SourceSpanWithContext) {
var context = (this as SourceSpanWithContext).context;
- var textIndex = context.indexOf(text.split('\n').first);
- var lineStart = context.lastIndexOf('\n', textIndex);
- if (lineStart != -1) {
- buffer.write(context.substring(0, lineStart + 1));
- context = context.substring(lineStart + 1);
+ var lineStart = findLineStart(context, text, column);
Siggi Cherem (dart-lang) 2015/03/31 01:07:49 text.split('\n').first was necessary before when F
+ if (lineStart > 0) {
+ buffer.write(context.substring(0, lineStart));
+ context = context.substring(lineStart);
}
var endIndex = context.indexOf('\n');
textLine = endIndex == -1 ? context : context.substring(0, endIndex + 1);
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/span_with_context.dart » ('j') | lib/src/utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698