Skip to content

fix: parse comparison file with parseAsync - #35

Merged
little-did-I-know merged 1 commit into
mainfrom
fix/compare-file-parse
Oct 30, 2026
Merged

little-did-I-know merged 1 commit into
mainfrom
fix/compare-file-parse

Conversation

@little-did-I-know

Copy link
Copy Markdown
Owner

Summary

Loading a comparison file (Compare File button) never worked: LayerComparison.loadCompareFile called p.parse(...), but GcodeParser only has parseAsync. The call threw inside FileReader.onload, so the callback that shows the toast, updates the diff stats and re-renders never ran.

  • src/comparison.js: the onload handler is now async and awaits p.parseAsync(text, file.name) before setting compareParser and calling the callback. LayerComparison is also exported so it can be tested; build.js strips the export.
  • test/comparison.test.js: new. It runs loadCompareFile with a fake FileReader and the fibreseeker_mini.gcode fixture, and checks the callback receives a parsed parser with layers and that getCompareMoves returns moves. I watched it fail first with p.parse is not a function.
  • gcode-modifier.html: rebuilt, as in earlier fix commits.

This bug was already on main and is unrelated to #34 (the Vortek HUD), which is why it is a separate branch.

Test plan

  • npm test: 378 of 378
  • New test failed before the fix (p.parse is not a function) and passes after
  • Not checked in a browser: Compare File with a real file
  • Parse errors still surface as an unhandled rejection with no toast. The old code threw uncaught in the same place, so I left that alone.

LayerComparison.loadCompareFile called p.parse(), which GcodeParser does not
have, so loading a compare file threw in FileReader.onload and the callback
never ran. Await parseAsync before invoking the callback.
@little-did-I-know
little-did-I-know merged commit f79da29 into main Oct 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant