feat: enable jsx element fold #16

Closed
hanchayi wants to merge 1 commit from feat/jsx-element-folder into main
hanchayi commented 2026-01-21 14:46:04 +01:00 (Migrated from github.com)
Add fold support for jsx element https://github.com/user-attachments/assets/91e0d4e6-c021-43a0-ae46-75ab0947f648
marijnh commented 2026-01-21 15:30:27 +01:00 (Migrated from github.com)

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?

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 commented 2026-01-22 05:38:01 +01:00 (Migrated from github.com)

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.

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.
marijnh commented 2026-01-22 09:25:45 +01:00 (Migrated from github.com)

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.

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 commented 2026-01-22 10:53:28 +01:00 (Migrated from github.com)

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

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

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/lang-javascript!16
No description provided.