summary refs log tree commit diff
path: root/src/libsyntax/errors/snippet/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-05-13 06:26:15 -0700
committerbors <bors@rust-lang.org>2016-05-13 06:26:15 -0700
commitedb6f83b89fc74afd6edce0bc98ea4f98a884455 (patch)
tree589a6db0c946d4b2354203d9466c89496dc78300 /src/libsyntax/errors/snippet/mod.rs
parenta581c82bdc2c13a398b091878d7353bc3d097d59 (diff)
parentc3310327552163e2d19bea1f38287dab22d38028 (diff)
downloadrust-edb6f83b89fc74afd6edce0bc98ea4f98a884455.tar.gz
rust-edb6f83b89fc74afd6edce0bc98ea4f98a884455.zip
Auto merge of #33513 - sanxiyn:tab-in-error, r=nikomatsakis
Better handling of tab in error

cc #33240.
Diffstat (limited to 'src/libsyntax/errors/snippet/mod.rs')
-rw-r--r--src/libsyntax/errors/snippet/mod.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libsyntax/errors/snippet/mod.rs b/src/libsyntax/errors/snippet/mod.rs
index 237e6823e0f..0699c6f4ac2 100644
--- a/src/libsyntax/errors/snippet/mod.rs
+++ b/src/libsyntax/errors/snippet/mod.rs
@@ -312,9 +312,15 @@ impl StyledBuffer {
             self.text[line][col] = chr;
             self.styles[line][col] = style;
         } else {
-            while self.text[line].len() < col {
-                self.text[line].push(' ');
+            let mut i = self.text[line].len();
+            while i < col {
+                let s = match self.text[0].get(i) {
+                    Some(&'\t') => '\t',
+                    _ => ' '
+                };
+                self.text[line].push(s);
                 self.styles[line].push(Style::NoStyle);
+                i += 1;
             }
             self.text[line].push(chr);
             self.styles[line].push(style);