Skip to content

Commit 7e9d3c6

Browse files
committed
StyledBuffer::prepend: if line is empty, insert content without inserting spaces
1 parent e97dded commit 7e9d3c6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/rustc_errors/src/styled_buffer.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ impl StyledBuffer {
105105
self.ensure_lines(line);
106106
let string_len = string.chars().count();
107107

108-
// Push the old content over to make room for new content
109-
for _ in 0..string_len {
110-
self.text[line].insert(0, StyledChar::default());
108+
if !self.text[line].is_empty() {
109+
// Push the old content over to make room for new content
110+
for _ in 0..string_len {
111+
self.text[line].insert(0, StyledChar::default());
112+
}
111113
}
112114

113115
self.puts(line, 0, string, style);

0 commit comments

Comments
 (0)