@@ -26,10 +26,27 @@ impl StyledBuffer {
26
26
}
27
27
}
28
28
29
- pub fn render ( & self ) -> Vec < Vec < StyledString > > {
29
+ pub fn copy_tabs ( & mut self , row : usize ) {
30
+ if row < self . text . len ( ) {
31
+ for i in row+1 ..self . text . len ( ) {
32
+ for j in 0 ..self . text [ i] . len ( ) {
33
+ if self . text [ row] . len ( ) > j &&
34
+ self . text [ row] [ j] == '\t' &&
35
+ self . text [ i] [ j] == ' ' {
36
+ self . text [ i] [ j] = '\t' ;
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ pub fn render ( & mut self ) -> Vec < Vec < StyledString > > {
30
44
let mut output: Vec < Vec < StyledString > > = vec ! [ ] ;
31
45
let mut styled_vec: Vec < StyledString > = vec ! [ ] ;
32
46
47
+ //before we render, do a little patch-up work to support tabs
48
+ self . copy_tabs ( 3 ) ;
49
+
33
50
for ( row, row_style) in self . text . iter ( ) . zip ( & self . styles ) {
34
51
let mut current_style = Style :: NoStyle ;
35
52
let mut current_text = String :: new ( ) ;
@@ -78,11 +95,7 @@ impl StyledBuffer {
78
95
} else {
79
96
let mut i = self . text [ line] . len ( ) ;
80
97
while i < col {
81
- let s = match self . text [ 0 ] . get ( i) {
82
- Some ( & '\t' ) => '\t' ,
83
- _ => ' ' ,
84
- } ;
85
- self . text [ line] . push ( s) ;
98
+ self . text [ line] . push ( ' ' ) ;
86
99
self . styles [ line] . push ( Style :: NoStyle ) ;
87
100
i += 1 ;
88
101
}
0 commit comments