fix get_last_nl_from_pos when error is last token (#2882)

pull/2906/head
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
1 changed files with 2 additions and 1 deletions

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