Skip to content

feat: enable jsx element fold#16

Closed
hanchayi wants to merge 1 commit intocodemirror:mainfrom
hanchayi:feat/jsx-element-folder
Closed

feat: enable jsx element fold#16
hanchayi wants to merge 1 commit intocodemirror:mainfrom
hanchayi:feat/jsx-element-folder

Conversation

@hanchayi
Copy link
Copy Markdown

@hanchayi hanchayi commented Jan 21, 2026

Add fold support for jsx element

jsx-folder.mp4

@marijnh
Copy link
Copy Markdown
Member

marijnh commented Jan 21, 2026

This doesn't typecheck. Also, the handling of self-closing elements seems a bit ad-hoc. Why fold those but not regular multi-line opening tags?

@hanchayi hanchayi force-pushed the feat/jsx-element-folder branch from 40810ea to ada160b Compare January 22, 2026 04:30
@hanchayi
Copy link
Copy Markdown
Author

Thank you for your valuable feedback! I apologize for the issues in the code - you're absolutely right about both the TypeScript errors and the inconsistent handling of different JSX tag types.

I've addressed these concerns by:

  1. Fixing TypeScript Type Safety : Added proper null checks and type guards throughout the JSX folding implementation to ensure it typechecks correctly.
  2. Creating Consistent Folding Logic : Updated the implementation to handle both self-closing tags and regular multi-line opening tags consistently:
    • For self-closing tags: Folds between the tag name and closing />
    • For regular tags: Folds between the opening tag and closing tag
  3. Adding Tests : Created test cases to verify the folding behavior works correctly for various JSX structures.

Again, thank you for pointing out these issues - your feedback helped improve the quality of this implementation.

@hanchayi hanchayi force-pushed the feat/jsx-element-folder branch 2 times, most recently from 8a40fc7 to 8664a94 Compare January 22, 2026 05:34
@hanchayi hanchayi force-pushed the feat/jsx-element-folder branch from 8664a94 to 0e1c833 Compare January 22, 2026 05:43
@marijnh marijnh closed this in a94cdcb Jan 22, 2026
@marijnh
Copy link
Copy Markdown
Member

marijnh commented Jan 22, 2026

Oh, I see, I'm not talking to a person, but a language model. In that case I don't want your code, so I've pushed an alternative implementation (attached). Please don't submit AI-generated pull requests again.

@hanchayi
Copy link
Copy Markdown
Author

I'm sorry. Indeed the comment is generated by ai, I'm not confident about my English. Thanks a lot Haha.

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.

2 participants