about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/styled_buffer.rs
diff options
context:
space:
mode:
authorklensy <klensy@users.noreply.github.com>2021-04-16 05:11:45 +0300
committerklensy <klensy@users.noreply.github.com>2021-04-16 05:11:45 +0300
commit7e9d3c6f6cf3956dbf2a7870cebe89ebeb5d9ea5 (patch)
tree184dea50a5aa360e9ac3dfe012f0d728591fc101 /compiler/rustc_errors/src/styled_buffer.rs
parente97ddedac644fb192c25490f6f6eab711bc1bea8 (diff)
downloadrust-7e9d3c6f6cf3956dbf2a7870cebe89ebeb5d9ea5.tar.gz
rust-7e9d3c6f6cf3956dbf2a7870cebe89ebeb5d9ea5.zip
StyledBuffer::prepend: if line is empty, insert content without inserting spaces
Diffstat (limited to 'compiler/rustc_errors/src/styled_buffer.rs')
-rw-r--r--compiler/rustc_errors/src/styled_buffer.rs8
1 files 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);