mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: fix bug with string.split_into_lines, when lines have extra CR's at their end (#16620)
This commit is contained in:
@ -849,11 +849,9 @@ pub fn (s string) split_into_lines() []string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
mut start := 0
|
mut start := 0
|
||||||
mut end := 0
|
|
||||||
for i := 0; i < s.len; i++ {
|
for i := 0; i < s.len; i++ {
|
||||||
if s[i] == 10 {
|
if s[i] == 10 {
|
||||||
end = if i > 0 && s[i - 1] == 13 { i - 1 } else { i }
|
res << if start == i { '' } else { s[start..i].trim_right('\r') }
|
||||||
res << if start == end { '' } else { s[start..end] }
|
|
||||||
start = i + 1
|
start = i + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user