Skip to content
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

Add folding and behaviours for JSX #5479

Merged
merged 6 commits into from
Apr 12, 2024
Merged

Conversation

mkslanc
Copy link
Contributor

@mkslanc mkslanc commented Feb 8, 2024

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: Patch coverage is 95.79832% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 86.63%. Comparing base (7dcfa41) to head (69c3fd9).
Report is 22 commits behind head on master.

Files Patch % Lines
src/edit_session/bracket_match.js 71.42% 2 Missing ⚠️
src/mode/folding/javascript.js 90.47% 2 Missing ⚠️
src/mode/folding/xml.js 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5479      +/-   ##
==========================================
+ Coverage   86.52%   86.63%   +0.10%     
==========================================
  Files         584      592       +8     
  Lines       42410    42812     +402     
  Branches     7060     7114      +54     
==========================================
+ Hits        36696    37090     +394     
- Misses       5714     5722       +8     
Flag Coverage Δ
unittests 86.63% <95.79%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nightwing
Copy link
Member

This does not work for several cases

  • return <> should become return <></>
  • <div>|</div> enter should indent properly
  • <div x={> should insert the closing }

@mkslanc mkslanc marked this pull request as draft February 22, 2024 09:07
@nightwing nightwing marked this pull request as ready for review March 25, 2024 21:30
@nightwing
Copy link
Member

@mkslanc i think this should fix the issues with highlighting without adding much complexity, could you please take a look, and add tests for pairing in x=`${`; and x=<a href={>

@mkslanc
Copy link
Contributor Author

mkslanc commented Mar 26, 2024

@mkslanc i think this should fix the issues with highlighting without adding much complexity, could you please take a look, and add tests for pairing in x=`${`; and x=<a href={>

Thank you! Sure, will do

@akoreman
Copy link
Contributor

Looks pretty good! I played around a bit with it and noticed one weird thing. In the video, the first time I insert <div> it doesn't auto-close and only the closing tag gets highlighted. If I do the same thing again below it, it does function as expected.

Screen.Recording.2024-04-12.at.13.48.46.mov

@nightwing
Copy link
Member

@akoreman The issue here is that after } our tokenizer is unable to distinguish between

q=function a(){
}
<div></div>

case when < is supposed to be treated as less than operator and

function a(){
}
<div></div>

where it is compiled as jsx tag.

same issue is present for regular expressions too, but since tags are usually not written in that context i am not sure if we need to add extra state for this case.

@akoreman
Copy link
Contributor

ah yeah that makes sense, in that case it should only occur in the scenario I used in the video which should not occur in valid JSX/TSX files anyway.

@nightwing nightwing merged commit 5671be6 into ajaxorg:master Apr 12, 2024
3 checks passed
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