From 7e9d3c6f6cf3956dbf2a7870cebe89ebeb5d9ea5 Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 16 Apr 2021 05:11:45 +0300 Subject: [PATCH] StyledBuffer::prepend: if line is empty, insert content without inserting spaces --- compiler/rustc_errors/src/styled_buffer.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_errors/src/styled_buffer.rs b/compiler/rustc_errors/src/styled_buffer.rs index a89d0aeaffd..9c19c96d64f 100644 --- a/compiler/rustc_errors/src/styled_buffer.rs +++ b/compiler/rustc_errors/src/styled_buffer.rs @@ -105,9 +105,11 @@ impl StyledBuffer { self.ensure_lines(line); let string_len = string.chars().count(); - // Push the old content over to make room for new content - for _ in 0..string_len { - self.text[line].insert(0, StyledChar::default()); + if !self.text[line].is_empty() { + // Push the old content over to make room for new content + for _ in 0..string_len { + self.text[line].insert(0, StyledChar::default()); + } } self.puts(line, 0, string, style);