1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix get_last_nl_from_pos when error is last token (#2882)

This commit is contained in:
joe-conigliaro 2019-11-25 20:58:22 +11:00 committed by GitHub
parent f7c103d5d2
commit 475807566d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -208,7 +208,8 @@ fn (s mut Scanner) goto_scanner_position(scp ScannerPos) {
s.last_nl_pos = scp.last_nl_pos
}
fn (s mut Scanner) get_last_nl_from_pos(pos int) int {
fn (s mut Scanner) get_last_nl_from_pos(_pos int) int {
mut pos := if _pos >= s.text.len { s.text.len-1 } else { _pos }
for i := pos; i >= 0; i-- {
if s.text[i] == `\n` {
return i