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

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
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/span_with_context.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/span_mixin.dart
diff --git a/lib/src/span_mixin.dart b/lib/src/span_mixin.dart
index a93723f10420335257147c6b55b4808534e8d542..b4503facdcca3a3e9d9518408a971c6beb01437f 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);
+ if (lineStart != null && 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698