-
Notifications
You must be signed in to change notification settings - Fork 7
Fix localized path for action scripts #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughOn script connection, emit a Global.ERROR notification when no menu item matches the script; sanitize assigned script names by removing all Changes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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 |
|
@coderabbitai, commit additional item to CHANGELOG.md file for this PR here. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 18479 @mkh-user, I cannot commit code directly to the repository. However, I can provide you with the changelog entry that should be added to the Here's the entry that should be added under the - Action scripts loading broken due to incorrect path globalization in `core/main.gd` ([#143](https://github.com/text-forge/text-forge/pull/143))This entry should be placed in the Would you like me to provide more details about where exactly to place this entry in the file? |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
core/main.gd(3 hunks)
🔇 Additional comments (2)
core/main.gd (2)
492-494: Core fix correctly addresses the path comparison issue.Globalizing the path at the source ensures consistency between path generation (line 209) and script connection (line 380). This resolves the bug where local paths failed to match the globalized paths returned by the resource loader.
Note: Line 211 now applies
S.globalize_path()to an already-globalized path, but sinceglobalize_path()is idempotent, this is safe. Optionally, you could remove the redundant call at line 211 for clarity.
402-402: > Likely an incorrect or invalid review comment.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
core/main.gd (1)
386-391: Early return correctly prevents configuring scripts for unmatched paths.This implements the previously requested early return: when no menu item matches
path, you now emit an error and exit before using the emptyitemdictionary, avoiding bogus script nodes and potential runtime issues. LGTM.
🧹 Nitpick comments (1)
core/main.gd (1)
201-220: Path globalization fix looks good; consider dropping now‑redundantS.globalize_pathcall.Standardizing
_get_script_path_for_itemto returnS.globalize_path(...)resolves the local vs global mismatch when comparing_get_script_path_for_item(option)topathin_connect_script, and keeps the same normalized base as used forscript.name.Given that change,
script_pathin_load_scriptsis already globalized, so the extraS.globalize_path(script_path)in theFileAccess.file_existscheck is redundant and can be simplified:- var script_path := _get_script_path_for_item(item) + var script_path := _get_script_path_for_item(item) # Disable items without script (except submenu roots) - if not FileAccess.file_exists(S.globalize_path(script_path)): + if not FileAccess.file_exists(script_path): if item.has("popup") and item.get("type", OptionTypes.REGULAR) != OptionTypes.SUBMENU: item.get("popup").set_item_disabled(item.get("popup").get_item_index(item.get("code", 0)), true)Not functionally broken as‑is, but this would tighten things up and make the data flow a bit clearer.
Also applies to: 380-381, 491-495
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
core/main.gd(3 hunks)
🔇 Additional comments (1)
core/main.gd (1)
403-403:script.namesanitization is clearer and matches path generation.Using
to_snake_case().remove_chars(".")makes the intent explicit and keeps the runtime script name aligned with the normalized base used for the script path. This is a straightforward readability and consistency win.
Summary of Changes
Adds globalization for action scripts paths for correct loading. Before this, in
core/main.gd:380local and global comparison always lead tofalseand leads to emptyitemfor all action scripts, this breaks startup.Related Items
Technical Details & Testing
Adds globalization for path generation, also checks for empty
itemvalues and improves readability with changing.remove_char(46)to.remove_chars(".").Checklist
Summary by CodeRabbit
Bug Fixes
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.