Skip to content

Commit

Permalink
also better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm committed Feb 27, 2025
1 parent 68c0f66 commit ed3da84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ export class CustomErrorListener implements ANTLRErrorListener<any> {
msg: string,
_e: RecognitionException | undefined,
): void {
let from = charPositionInLine;
if (offendingSymbol?.text === '<EOF>') {
from = 0;
}
this.errors.push({
message: msg,
offendingSymbol: offendingSymbol?.text,
from: charPositionInLine,
from,
to: charPositionInLine + (offendingSymbol?.text?.length ?? Infinity),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export const useSelectionInputLintingAndHighlighting = ({
return null;
}
if (error.error.offendingSymbol) {
const symbol = error.error.offendingSymbol;
if (symbol === '<EOF>') {
return 'Selection is incomplete';
}
return (
<Box flex={{direction: 'row', alignItems: 'center'}}>
Unexpected input
Expand Down

0 comments on commit ed3da84

Please sign in to comment.