mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +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:
parent
7091010a53
commit
eb88f7e255
1 changed files with 1 additions and 3 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue