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

Unified Diff: runtime/observatory/lib/src/elements/script_inset.dart

Issue 849263002: Introduce elipses when there are long stretches of blank lines in observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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: runtime/observatory/lib/src/elements/script_inset.dart
diff --git a/runtime/observatory/lib/src/elements/script_inset.dart b/runtime/observatory/lib/src/elements/script_inset.dart
index 814c45f61988a8e9b18b84bb7c6f26fca738a71b..d7661313abfb001e1193c9ee030872057d658657 100644
--- a/runtime/observatory/lib/src/elements/script_inset.dart
+++ b/runtime/observatory/lib/src/elements/script_inset.dart
@@ -9,6 +9,14 @@ import 'observatory_element.dart';
import 'package:observatory/service.dart';
import 'package:polymer/polymer.dart';
+class ScriptElipsis {
+ ScriptElipsis(this.start, this.end);
+ int line = null;
Cutch 2015/01/15 21:58:16 remove this
+
+ final int start;
+ final int end;
+}
+
/// Box with script source code in it.
@CustomTag('script-inset')
class ScriptInsetElement extends ObservatoryElement {
@@ -27,7 +35,8 @@ class ScriptInsetElement extends ObservatoryElement {
@observable int endLine;
@observable bool linesReady = false;
- @observable List<ScriptLine> lines = toObservable([]);
+ // Contents are either ScriptLine or ScriptElipsis.
+ @observable List lines = toObservable([]);
String makeLineId(int line) {
return 'line-$line';
@@ -112,8 +121,30 @@ class ScriptInsetElement extends ObservatoryElement {
: script.lines.length);
lines.clear();
+ int blankLineCount = 0;
for (int i = (startLine - 1); i <= (endLine - 1); i++) {
- lines.add(script.lines[i]);
+ if (script.lines[i].isBlank) {
+ // Try to introduce elipses if there are 4 or more contiguous blank lines.
+ blankLineCount++;
+ } else {
+ if (blankLineCount > 0) {
+ int firstBlank = i - blankLineCount;
+ int lastBlank = i - 1;
+ if (blankLineCount < 4) {
+ // Too few blank lines for an elipsis.
+ for (int j = firstBlank; j <= lastBlank; j++) {
+ lines.add(script.lines[j]);
+ }
+ } else {
+ // Add an elipsis for the skipped region.
+ lines.add(script.lines[firstBlank]);
+ lines.add(new ScriptElipsis(firstBlank + 1, lastBlank - 1));
+ lines.add(script.lines[lastBlank]);
+ }
+ blankLineCount = 0;
+ }
+ lines.add(script.lines[i]);
+ }
}
linesReady = true;
}

Powered by Google App Engine
This is Rietveld 408576698