Skip to content

Scripting terminal: only bind cards to top-level declarations - #94

Merged
rubensworks merged 1 commit into
master-1.21-ltsfrom
terminal-ux-clean/9-toplevel-binding
Oct 19, 2026
Merged

rubensworks merged 1 commit into
master-1.21-ltsfrom
terminal-ux-clean/9-toplevel-binding

Conversation

@rubensworks

Copy link
Copy Markdown
Member

Stacked on #93.

Before, moving the cursor through a function body rebound the card to the word under the cursor, for example item or itemstackIsStackable. Those can't be evaluated as script members, so the card broke just from navigating.

Now, when nothing is selected, the cursor only selects names of top-level function/class/var/let/const declarations. On any other word, the previous selection is kept if it's still declared in the script, and is cleared otherwise. That way, switching scripts never carries over a name from another file. Explicit text selections behave as before.

How it works: the top-level names come from a lightweight scanner, JavaScriptDeclarations. It skips strings, template literals, comments and regexes, and ignores function/class expressions and member accesses. For destructuring declarations it returns null, and the terminal then falls back to the old behavior instead of blocking a valid binding. It's exposed as ILanguageHandler.getTopLevelMembers, which returns null by default.

Validation:

  • Unit tests in JavaScriptDeclarationsTest.
  • In-game: clicking filterItem and then a word inside its body keeps "Binds to: filterItem". It used to switch to itemstackIsSt….
  • build and runGameTestServer (23/23) pass.

Generated by Claude Code

@coveralls

coveralls commented Oct 18, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 39205496783

Coverage increased (+1.4%) to 44.465%

Details

  • Coverage increased (+1.4%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 212 coverage regressions across 4 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

212 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
org/cyclops/integratedscripting/client/gui/container/ContainerScreenTerminalScripting.java 203 0.0%
org/cyclops/integratedscripting/core/language/LanguageHandlerJavaScript.java 6 86.75%
org/cyclops/integratedscripting/api/language/ILanguageHandler.java 2 0.0%
org/cyclops/integratedscripting/core/network/ScriptingData.java 1 80.41%

Coverage Stats

Coverage Status
Relevant Lines: 3769
Covered Lines: 1794
Line Coverage: 47.6%
Relevant Branches: 1723
Covered Branches: 648
Branch Coverage: 37.61%
Branches in Coverage %: Yes
Coverage Strength: 23.44 hits per line

💛 - Coveralls

Moving the cursor through a function body rebound the card to whichever
word was under the cursor, such as a parameter or a method name, which can
not be evaluated. The cursor now only selects names of top-level functions,
classes and variables, and keeps the previous one otherwise. Explicit
selections are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
@rubensworks
rubensworks force-pushed the terminal-ux-clean/8-wrap-and-create branch from 9f57696 to ee16f1a Compare October 19, 2026 05:37
@rubensworks
rubensworks force-pushed the terminal-ux-clean/9-toplevel-binding branch from 856c391 to 62276da Compare October 19, 2026 05:37
Base automatically changed from terminal-ux-clean/8-wrap-and-create to master-1.21-lts October 19, 2026 17:51
@rubensworks
rubensworks merged commit d27867b into master-1.21-lts Oct 19, 2026
23 of 34 checks passed
@rubensworks
rubensworks deleted the terminal-ux-clean/9-toplevel-binding branch October 19, 2026 17:54
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.

3 participants