File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -463,7 +463,7 @@ fn format_lines(
463
463
is_string = false ;
464
464
} else {
465
465
newline_count = 0 ;
466
- line_len += 1 ;
466
+ line_len += if c == '\t' { config . tab_spaces ( ) } else { 1 } ;
467
467
if c. is_whitespace ( ) {
468
468
if last_wspace. is_none ( ) {
469
469
last_wspace = Some ( b) ;
Original file line number Diff line number Diff line change @@ -261,6 +261,16 @@ fn format_lines_errors_are_reported() {
261
261
assert ! ( error_summary. has_formatting_errors( ) ) ;
262
262
}
263
263
264
+ #[ test]
265
+ fn format_lines_errors_are_reported_with_tabs ( ) {
266
+ let long_identifier = String :: from_utf8 ( vec ! [ b'a' ; 97 ] ) . unwrap ( ) ;
267
+ let input = Input :: Text ( format ! ( "fn a() {{\n \t {}\n }}" , long_identifier) ) ;
268
+ let config = Config :: from_toml ( "hard_tabs = true" ) . unwrap ( ) ;
269
+ let ( error_summary, _file_map, _report) =
270
+ format_input :: < io:: Stdout > ( input, & config, None ) . unwrap ( ) ;
271
+ assert ! ( error_summary. has_formatting_errors( ) ) ;
272
+ }
273
+
264
274
// For each file, run rustfmt and collect the output.
265
275
// Returns the number of files checked and the number of failures.
266
276
fn check_files ( files : Vec < PathBuf > ) -> ( Vec < FormatReport > , u32 , u32 ) {
You can’t perform that action at this time.
0 commit comments