Fix Tab-to-accept crashing for user-defined function completions - #4273
Open
NisargJasani0602 wants to merge 1 commit into
Open
Fix Tab-to-accept crashing for user-defined function completions#4273NisargJasani0602 wants to merge 1 commit into
NisargJasani0602 wants to merge 1 commit into
Conversation
buildVarOrFunctionOption() expects state and pos as separate positional arguments (matching its sibling builders), but its call site was bundling them inside the options object instead, leaving both undefined. The resulting apply() closure then threw "Cannot read properties of undefined (reading 'doc')" when accepting a user-defined function completion via Tab, which the Tab keymap handler swallowed as "unhandled" and fell through without inserting anything. Fixes processing#4272
NisargJasani0602
requested a deployment
to
e2e-tests
August 30, 2026 20:38 — with
GitHub Actions
Waiting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4272
Issue:
buildVarOrFunctionOption()incontextAwareHinter.jsexpectsstateandposas separate positional arguments (matching its sibling builders,buildMethodOptionandbuildGlobalHintOption), but its call site was bundlingthem as properties inside the options object instead. Since the function's destructuring pattern doesn't include
state/pos, both silently ended upundefinedinside the function.That
undefinedstategot captured in the completion'sapplyclosure. When accepting a user-defined function completion via Tab,state.doc.lineAt(pos)threwTypeError: Cannot read properties of undefined (reading 'doc'). The Tabkeymap handler treats a failed accept as "unhandled" and falls through to the next binding, so nothing got inserted — matching the reported bug.
This only affected completions for user-defined functions/variables from the app's custom hinter; built-in p5 keywords and CodeMirror's own local-scope suggestions were unaffected (which is why the popup could show two entries for
the same identifier — one broken, one fine).
Changes:
buildVarOrFunctionOption()call site inclient/utils/contextAwareHinter.jsto passstateandposas separate trailing arguments instead of bundling them inside the options object.I have verified that this pull request:
npm run lint)npm run test)npm run typecheck)developbranch.Fixes #123