Skip to content

Commit 41d2411

Browse files
authored
Fix how spans are rendered in the debug output. (#1168)
A while back, I did a big refactoring where each Chunk's split now describes the line split before that Chunk's text instead of after. When I did that, it looks like I didn't update how the debug output draws spans. Since this is only used for debugging the formatter, it doesn't affect users. But it make for some very confusing debugging for me.
1 parent 73c0cb7 commit 41d2411

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lib/src/debug.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,31 @@ void dumpChunks(int start, List<Chunk> chunks) {
127127
var spanBars = '';
128128
for (var span in spans) {
129129
if (chunk.spans.contains(span)) {
130-
if (index == 0 || !chunks[index - 1].spans.contains(span)) {
130+
if (index == chunks.length - 1 ||
131+
!chunks[index + 1].spans.contains(span)) {
132+
// This is the last chunk with the span.
133+
spanBars += '╙';
134+
} else {
135+
spanBars += '║';
136+
}
137+
} else {
138+
// If the next chunk has this span, then show it bridging this chunk
139+
// and the next because a split between them breaks the span.
140+
if (index < chunks.length - 1 &&
141+
chunks[index + 1].spans.contains(span)) {
131142
if (span.cost == 1) {
132143
spanBars += '╓';
133144
} else {
134145
spanBars += span.cost.toString();
135146
}
136-
} else {
137-
spanBars += '║';
138-
}
139-
} else {
140-
if (index > 0 && chunks[index - 1].spans.contains(span)) {
141-
spanBars += '╙';
142-
} else {
143-
spanBars += ' ';
144147
}
145148
}
146149
}
147150
row.add(spanBars);
148151
}
149152

153+
row.add(chunk.spans.map((span) => span.id).join(' '));
154+
150155
if (chunk.text.length > 70) {
151156
row.add(chunk.text.substring(0, 70));
152157
} else {

0 commit comments

Comments
 (0)