File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
src/org/rascalmpl/library/lang/json/internal Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -492,7 +492,10 @@ private int getPos() {
492492 var trackerCount = tracker .getReadCount ();
493493
494494 if (readCount < trackerCount ) {
495+ // the tracker indicates that `read` has happened and so the buffer has been rewound.
495496 readCount = trackerCount ;
497+ // we learn from the tracker how far the offset is until the new first character in the buffer
498+ // and we add the current offset since that reset to found our new current offset.
496499 offset = tracker .getLimitOffset () + internalPos ;
497500 }
498501 else {
@@ -504,6 +507,7 @@ private int getPos() {
504507 lastPos = internalPos ;
505508
506509 try {
510+ // never go below 0. might happen with a parse error at the first character.
507511 return Math .max (0 , offset - 1 );
508512 }
509513 catch (IllegalArgumentException | SecurityException e ) {
You can’t perform that action at this time.
0 commit comments