Skip to content

Commit ebae628

Browse files
committed
feat: Style : for titles
1 parent a2ce03e commit ebae628

19 files changed

+26
-23
lines changed

examples/expected_type.svg

+1-1
Loading

examples/footer.svg

+1-1
Loading

examples/format.svg

+1-1
Loading

examples/multislice.svg

+1-1
Loading

src/renderer/display_list.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,18 @@ impl DisplaySet<'_> {
160160
&self,
161161
line_offset: usize,
162162
label: &[DisplayTextFragment<'_>],
163+
needs_colon: bool,
163164
stylesheet: &Stylesheet,
164165
buffer: &mut StyledBuffer,
165166
) -> fmt::Result {
166-
for fragment in label {
167+
for (i, fragment) in label.iter().enumerate() {
167168
let style = match fragment.style {
168169
DisplayTextStyle::Regular => stylesheet.none(),
169170
DisplayTextStyle::Emphasis => stylesheet.emphasis(),
170171
};
172+
if i == 0 && needs_colon {
173+
buffer.append(line_offset, ": ", *style);
174+
}
171175
buffer.append(line_offset, fragment.content, *style);
172176
}
173177
Ok(())
@@ -191,10 +195,10 @@ impl DisplaySet<'_> {
191195
for _ in 0..formatted_len + 2 {
192196
buffer.append(line_offset, " ", Style::new());
193197
}
194-
return self.format_label(line_offset, &annotation.label, stylesheet, buffer);
198+
return self.format_label(line_offset, &annotation.label, false, stylesheet, buffer);
195199
}
196200
if formatted_len == 0 {
197-
self.format_label(line_offset, &annotation.label, stylesheet, buffer)
201+
self.format_label(line_offset, &annotation.label, false, stylesheet, buffer)
198202
} else {
199203
let id = match &annotation.id {
200204
Some(id) => format!("[{id}]"),
@@ -207,8 +211,7 @@ impl DisplaySet<'_> {
207211
);
208212

209213
if !is_annotation_empty(annotation) {
210-
buffer.append(line_offset, ": ", stylesheet.none);
211-
self.format_label(line_offset, &annotation.label, stylesheet, buffer)?;
214+
self.format_label(line_offset, &annotation.label, true, stylesheet, buffer)?;
212215
}
213216
Ok(())
214217
}

tests/fixtures/color/ann_eof.svg

+1-1
Loading

tests/fixtures/color/ann_insertion.svg

+1-1
Loading

tests/fixtures/color/ann_multiline.svg

+1-1
Loading

tests/fixtures/color/ann_multiline2.svg

+1-1
Loading

tests/fixtures/color/ann_removed_nl.svg

+1-1
Loading

tests/fixtures/color/ensure-emoji-highlight-width.svg

+1-1
Loading

tests/fixtures/color/fold_ann_multiline.svg

+1-1
Loading

tests/fixtures/color/fold_leading.svg

+1-1
Loading

tests/fixtures/color/fold_trailing.svg

+1-1
Loading

tests/fixtures/color/issue_9.svg

+1-1
Loading

tests/fixtures/color/simple.svg

+1-1
Loading

tests/fixtures/color/strip_line.svg

+1-1
Loading

tests/fixtures/color/strip_line_char.svg

+1-1
Loading

tests/fixtures/color/strip_line_non_ws.svg

+1-1
Loading

0 commit comments

Comments
 (0)