Skip to content

Commit

Permalink
Automatically indent JSX (zed-industries#18816)
Browse files Browse the repository at this point in the history
indents jsx in a way that is [consistent with
html](https://github.com/zed-industries/zed/blob/main/extensions/html/languages/html/indents.scm)

before, no automatic indentation would apply and it would even dedent
you when you add a line above the cursor (shift-o in vim mode)


https://github.com/user-attachments/assets/470fbdb2-3e31-42c4-b535-bb26ae1706ab


after, it applies automatic indentation when you hit return


https://github.com/user-attachments/assets/e86c739d-370d-490d-8c6f-d0190e65f832



Closes zed-industries#16127

Release Notes:

- Improved automatic indentation behavior in JSX
([zed-industries#16127](zed-industries#16127))
  • Loading branch information
schpet authored Oct 10, 2024
1 parent d2b4fa2 commit 972886c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/languages/src/javascript/indents.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
(_ "<" ">" @end) @indent
(_ "{" "}" @end) @indent
(_ "(" ")" @end) @indent

(jsx_opening_element ">" @end) @indent

(jsx_element
(jsx_opening_element) @start
(jsx_closing_element)? @end) @indent
6 changes: 6 additions & 0 deletions crates/languages/src/tsx/indents.scm
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
(_ "<" ">" @end) @indent
(_ "{" "}" @end) @indent
(_ "(" ")" @end) @indent

(jsx_opening_element ">" @end) @indent

(jsx_element
(jsx_opening_element) @start
(jsx_closing_element)? @end) @indent

0 comments on commit 972886c

Please sign in to comment.