Fix case-insensitive input handling for all string setters in accessors#168
Fix case-insensitive input handling for all string setters in accessors#168jgphilpott merged 3 commits intomainfrom
Conversation
Co-authored-by: jgphilpott <4128208+jgphilpott@users.noreply.github.com>
|
Great catch @copilot, here are some more things to do:
All setters should be able to take input in capitalized or non-capitalized form but save the value in capitalized form so that the getter returns the proper format. |
…xtruderMode; add catch-all test Co-authored-by: jgphilpott <4128208+jgphilpott@users.noreply.github.com>
Done in commit Additional setters fixed (same
New tests added:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes case-insensitive handling in Polyslice’s string-based configuration setters so valid inputs aren’t silently rejected due to casing/camelCase mismatches (notably restoring correct supportPlacement switching behavior that affected support generation outcomes).
Changes:
- Normalize inputs in key string setters (speed unit, support placement, positioning mode, extruder mode) while storing canonical values.
- Add/extend regression tests to ensure case-insensitive setter behavior (including a broad “all string setters” guard test).
- Regenerate affected support G-code fixture outputs (LFS pointers updated) to reflect corrected configuration handling.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/accessors.coffee | Implements case-insensitive normalization and canonical storage for affected string setters. |
| src/utils/accessors.test.coffee | Adds targeted + catch-all tests ensuring string setters accept case-insensitive inputs and store canonical values. |
| src/slicer/support/support.test.coffee | Adds regression test for switching supportPlacement from everywhere back to buildPlate. |
| resources/gcode/support/tree/dome/sideways-buildPlate.gcode | Updates LFS pointer for regenerated fixture output after config-handling fix. |
| resources/gcode/support/tree/arch/sideways-buildPlate.gcode | Updates LFS pointer for regenerated fixture output after config-handling fix. |
| resources/gcode/support/threshold/80-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/70-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/60-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/50-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/40-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/30-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/20-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/10-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/threshold/0-degrees.gcode | Updates LFS pointer for regenerated threshold fixture output. |
| resources/gcode/support/normal/dome/sideways-buildPlate.gcode | Updates LFS pointer for regenerated fixture output reflecting corrected buildPlate placement behavior. |
| resources/gcode/support/normal/dome/flipped.gcode | Updates LFS pointer for regenerated fixture output. |
Several string setters in
src/utils/accessors.coffeesilently ignored valid input when the casing didn't exactly match the canonical stored value. The most impactful instance wassetSupportPlacement('buildPlate')failing after a priorsetSupportPlacement('everywhere')call, causing the sideways dome withbuildPlateplacement to generate 95 spurious support lines instead of 0.Root Cause
toLowerCase()converts camelCase input to all-lowercase, which then fails to match camelCase entries in validation arrays:The same pattern affected
setSpeedUnit(which had notoLowerCase()at all, requiring exact-match for camelCase values like"millimeterSecond"), andsetPositioningMode/setExtruderMode(which had notoLowerCase(), so"Relative"or"ABSOLUTE"silently failed).Fix
Normalize input to lowercase for comparison, then store the canonical form:
The same approach is applied to
setSpeedUnit. ForsetPositioningModeandsetExtruderMode, atoLowerCase()call is added before the existing array check (no canonical remapping needed since values are already lowercase).Changes
src/utils/accessors.coffee— fixed four setters:setSupportPlacement: normalize + compare lowercase + store canonical camelCasesetSpeedUnit: addedtoLowerCase()normalization; maps to canonical"millimeterSecond","inchSecond","meterSecond"setPositioningMode: addedtoLowerCase()before comparisonsetExtruderMode: addedtoLowerCase()before comparisonsrc/slicer/support/support.test.coffee— regression test: set to'everywhere', then back to'buildPlate', assert value is'buildPlate'src/utils/accessors.test.coffee— added:should set and get speed unit— covers all three speed unit values and case variantssetPositioningModeandsetExtruderModetestsshould accept case-insensitive input for all string setters— catch-all test covering all 14 string setters with uppercase input to prevent future regressionsresources/gcode/support/normal/dome/sideways-buildPlate.gcode— regenerated; support line count drops from 95 → 0🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.