Skip to content

Commit

Permalink
libnixf: fix Lexer location indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Jan 20, 2024
1 parent 62d3a0a commit 5a28b6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libnixf/src/Parse/Lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions libnixf/test/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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], "''");
Expand All @@ -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(), "''");
}

Expand Down

0 comments on commit 5a28b6c

Please sign in to comment.