Skip to content

Commit

Permalink
Make the CST builder more NaN resistant
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Jul 28, 2023
1 parent 8e7ed4b commit e605318
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/langium/src/parser/cst-node-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class CompositeCstNodeImpl extends AbstractCstNode implements CompositeCs

private get firstNonHiddenNode(): CstNode | undefined {
for (const child of this.content) {
if (!child.hidden) {
if (!child.hidden && !isNaN(child.offset)) {
return child;
}
}
Expand All @@ -235,7 +235,7 @@ export class CompositeCstNodeImpl extends AbstractCstNode implements CompositeCs
private get lastNonHiddenNode(): CstNode | undefined {
for (let i = this.content.length - 1; i >= 0; i--) {
const child = this.content[i];
if (!child.hidden) {
if (!child.hidden && !isNaN(child.end)) {
return child;
}
}
Expand Down

0 comments on commit e605318

Please sign in to comment.