Skip to content

Commit

Permalink
Confirm token equality, safer loop
Browse files Browse the repository at this point in the history
Using different variable to iterate to guarantee unchanged behaviour
if anything doesn't work as intended.
  • Loading branch information
danielzuncke authored and WebFreak001 committed Oct 18, 2023
1 parent c0452db commit 08fe5d6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/dfmt/formatter.d
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,17 @@ private:

// Account for possible function literals in this array which offset
// the previously set index (pos). Fixes issue #432.
while(astInformation.indentInfoSortedByEndLocation[pos].endLocation !=
size_t newPos = pos;
while(astInformation.indentInfoSortedByEndLocation[newPos].endLocation <
tokens[index].index)
{
pos++;
newPos++;
}

if (astInformation.indentInfoSortedByEndLocation[newPos].endLocation ==
tokens[index].index)
{
pos = newPos;
}

auto indentInfo = astInformation.indentInfoSortedByEndLocation[pos];
Expand Down

0 comments on commit 08fe5d6

Please sign in to comment.