File tree 4 files changed +23
-3
lines changed
4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,18 @@ Types of changes
17
17
- Security in case of vulnerabilities.
18
18
-->
19
19
20
+ ### Fixed
21
+
22
+ - Multiline strings are handled as utf-8 correctly, preventing panics
23
+ on utf-8 whitespace like:
24
+
25
+ ``` nix
26
+ ''
27
+ foo
28
+ \u{2002}bar
29
+ ''
30
+ ```
31
+
20
32
## [ 0.5.0] - 2022-02-23
21
33
22
34
### Changed
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ pub fn rule(
73
73
if !line. is_empty ( ) {
74
74
indentation = usize:: min (
75
75
indentation,
76
- line. len ( ) - line. trim_start ( ) . len ( ) ,
76
+ line. chars ( ) . count ( ) - line. trim_start ( ) . chars ( ) . count ( ) ,
77
77
) ;
78
78
}
79
79
}
@@ -85,8 +85,8 @@ pub fn rule(
85
85
lines = lines
86
86
. iter ( )
87
87
. map ( |line| {
88
- if indentation < line. len ( ) {
89
- line[ indentation..line . len ( ) ] . to_string ( )
88
+ if indentation < line. chars ( ) . count ( ) {
89
+ line. chars ( ) . skip ( indentation ) . collect :: < String > ( )
90
90
} else {
91
91
line. to_string ( )
92
92
}
Original file line number Diff line number Diff line change 1
1
[
2
+ ''
3
+ foo
4
+ bar
5
+ ''
2
6
""
3
7
###
4
8
"
Original file line number Diff line number Diff line change 1
1
[
2
+ ''
3
+ foo
4
+ bar
5
+ ''
2
6
""
3
7
###
4
8
"
You can’t perform that action at this time.
0 commit comments