diff --git a/libnixf/src/Parse/Lexer.h b/libnixf/src/Parse/Lexer.h index 7599e13ca..a90a38bbb 100644 --- a/libnixf/src/Parse/Lexer.h +++ b/libnixf/src/Parse/Lexer.h @@ -30,7 +30,7 @@ class Lexer { assert(Cur.Offset + N <= Src.length()); // Update Line & Column & Offset for (std::size_t I = 0; I < N; ++I) { - if (Src[Cur.Offset + N] == '\n') { + if (Src[Cur.Offset + I] == '\n') { ++Cur.Line; Cur.Column = 0; } else { diff --git a/libnixf/test/Parse/Parser.cpp b/libnixf/test/Parse/Parser.cpp index b0ec735e9..0dd8f4ebd 100644 --- a/libnixf/test/Parse/Parser.cpp +++ b/libnixf/test/Parse/Parser.cpp @@ -155,8 +155,8 @@ TEST(Parser, IndentedString) { // Check the diagnostic. ASSERT_EQ(Diags.size(), 1); auto &D = Diags[0]; - ASSERT_TRUE(D.range().begin().isAt(7, 3, 39)); - ASSERT_TRUE(D.range().end().isAt(7, 3, 39)); + ASSERT_TRUE(D.range().begin().isAt(7, 2, 39)); + ASSERT_TRUE(D.range().end().isAt(7, 2, 39)); ASSERT_EQ(D.kind(), Diagnostic::DK_Expected); ASSERT_EQ(D.args().size(), 1); ASSERT_EQ(D.args()[0], "''"); @@ -173,8 +173,8 @@ TEST(Parser, IndentedString) { // Check fix-it hints. ASSERT_EQ(D.fixes().size(), 1); const auto &F = D.fixes()[0]; - ASSERT_TRUE(F.oldRange().begin().isAt(7, 3, 39)); - ASSERT_TRUE(F.oldRange().end().isAt(7, 3, 39)); + ASSERT_TRUE(F.oldRange().begin().isAt(7, 2, 39)); + ASSERT_TRUE(F.oldRange().end().isAt(7, 2, 39)); ASSERT_EQ(F.newText(), "''"); }