fix: constants silently dropped when pressing Enter in LD/FBD autocomplete#642
fix: constants silently dropped when pressing Enter in LD/FBD autocomplete#642thiagoralves wants to merge 1 commit into
Conversation
…plete
When typing a constant (e.g. T#500ms, 5, 'hello') on a block input/output
and pressing Enter, the autocomplete tried to create a new variable with
that name. Since constants fail isLegalIdentifier(), this showed an
"Illegal variable name" toast and returned early without updating the node.
In LD, the blur handler (which correctly handles constants) was also
suppressed by blur({ submit: false }), causing the constant to be silently
dropped — the input appeared to accept the value but compiled as 0.
Fix: detect literals via getLiteralType() in two layers:
- Autocomplete submit functions (LD + FBD): skip createVariable for literals
- LD Enter handlers (variable, contact, coil): pass submit:true for literals
so the blur handler processes them with proper type validation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Repository UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (5)
WalkthroughThe PR adds guards using Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
T#500ms,5,'hello') on a block input/output and pressing Enter showed an "Illegal variable name" toast and silently dropped the value — the input appeared accepted (yellow text) but compiled as 0createVariable(), which rejects literals viaisLegalIdentifier(). In LD,blur({ submit: false })then suppressed the blur handler that would have correctly processed the constantFix
Detect literals via
getLiteralType()in two layers:submitfunctions (LD + FBD): skipcreateVariable()for literals — prevents the error toastsubmit: truefor literals so the blur handler processes them with proper type validationAll IEC 61131-3 literal types are covered: numeric, time, date, TOD, datetime, string, and boolean constants.
Test plan
T#500mson PT input, press Enter → no error toast, value accepted (yellow text), compiles correctly5on an INT input,3.14on a REAL input,TRUEon a BOOL contactT#500mstest in FBD editor → no error toast, value accepted🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes