fix: skip auto-formatting JSON inputs#64
fix: skip auto-formatting JSON inputs#64Moeblack wants to merge 2 commits intonewtextdoc1111:mainfrom
Conversation
Avoid corrupting JSON textareas by skipping auto-formatter when the content looks like JSON. Adds a unit test.
There was a problem hiding this comment.
Thank you for your contribution!
Upon reviewing the code, I found that scheduling syntax used by comfyui-prompt-control extension is being incorrectly identified as JSON content. I have added two suggestions as inline comments on the source code. I would appreciate it if you could verify whether these changes work correctly in your environment.
Suggestions
- Use
JSON.parsefor JSON content detection - Add unit tests for prompts containing comfyui-prompt-control scheduling syntax
P.S. About the GitHub Action error, I'll fix it after merging this PR.
Apply maintainer suggestions to strictly use JSON.parse for JSON detection. Also update the wordCommaPattern to correctly match non-alphanumeric trailing tokens (e.g. comfyui-prompt-control scheduling syntax), ensuring they are correctly auto-formatted. Add tests for scheduling syntax.
|
Thank you for the review and the suggestions. I have applied the changes to use \JSON.parse\ for JSON detection and added the unit tests for the \comfyui-prompt-control\ scheduling syntax. During testing, the scheduling syntax tests initially failed because the original \wordCommaPattern\ (/\w+\s*,/g) did not match the closing bracket ]. I updated the regex to /[^\s,]+\s*,/g\ to ensure these tokens are correctly captured. All tests are now passing. Please let me know if anything else is needed. |
Summary
Why
Autocomplete-Plus auto-formatting is designed for comma-separated prompt tags. When users paste JSON into a multiline textarea (e.g. used as structured prompt schema), formatting on blur can remove JSON commas and break the JSON.
Test plan