fix inclusive offsets in cpp test

This commit is contained in:
Clément Fournier
2022-07-17 17:55:38 +02:00
parent 63c01f0f5b
commit 227e27c369
2 changed files with 15 additions and 16 deletions

View File

@ -76,14 +76,13 @@ final class FragmentedTextDocument extends BaseMappedDocument implements TextDoc
lastAccessedFragment = f;
}
if (!inclusive && f.outEnd() == outOffset) {
if (f.next != null) {
if (inclusive && f.outEnd() == outOffset && f.next != null) {
// Inclusive means, the offset must correspond to a character in the source document.
// Here we have to skip forward to the fragment that contains the character, because
// it's not this one.
do {
f = f.next;
lastAccessedFragment = f;
// fallthrough
} else {
return f.outToIn(outOffset) + 1;
}
} while (f.next != null && f.outLen() == 0);
}
return f.outToIn(outOffset);
}

View File

@ -1,14 +1,14 @@
[Image] or [Truncated image[ Bcol Ecol
L1
[void] 1 2
L5
[main] 2 2
L9
[(] 2 2
L6
[main] 1 2
L10
[)] 2 2
L12
[{] 2 2
L14
[}] 2 2
[(] 1 2
L11
[)] 1 2
L13
[{] 1 2
L15
[}] 1 2
EOF