Skip to content

Commit

Permalink
[JavaScript] Simplify indentation rules
Browse files Browse the repository at this point in the history
By utilizing the improved selector scoring of build 4173, we can simply
have the two rules override each other based on the last meta scope on
the stack.
  • Loading branch information
FichteFoll committed Aug 25, 2024
1 parent a644c0e commit dfad440
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
19 changes: 7 additions & 12 deletions JavaScript/Indentation Rules - Values.tmPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
<dict>
<key>scope</key>
<string>
(source.js meta.mapping, source.js meta.sequence) - source.js meta.function,
source.js meta.function meta.mapping,
source.js meta.function meta.sequence,
(source.jsx meta.mapping, source.jsx meta.sequence) - source.jsx meta.function,
source.jsx meta.function meta.mapping,
source.jsx meta.function meta.sequence,
(source.ts meta.mapping, source.ts meta.sequence) - source.ts meta.function,
source.ts meta.function meta.mapping,
source.ts meta.function meta.sequence,
(source.tsx meta.mapping, source.tsx meta.sequence) - source.tsx meta.function,
source.tsx meta.function meta.mapping,
source.tsx meta.function meta.sequence
source.js meta.mapping, source.js meta.sequence,
source.jsx meta.mapping, source.jsx meta.sequence,
source.ts meta.mapping, source.ts meta.sequence,
source.tsx meta.mapping, source.tsx meta.sequence
</string>
<key>settings</key>
<dict>
Expand Down Expand Up @@ -72,6 +64,9 @@
($|/[/*])
)
</string>
<!-- Reset for value rules -->
<key>bracketIndentNextLinePattern</key>
<string></string>
</dict>
</dict>
</plist>
23 changes: 15 additions & 8 deletions JavaScript/Indentation Rules.tmPreferences
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<!--
The meta.function scopes are used
to re-override the separate mapping and sequence-sepcific patterns
defined in `Indentation Rules - Values.tmPreferences`.
This relies on a scope selector scoring adjustment in 4173.
See also: https://github.com/sublimehq/sublime_text/issues/2152
-->
<key>scope</key>
<string>
source.js - source.js meta.mapping - source.js meta.sequence - source.js meta.string,
source.js meta.function,
source.jsx - source.jsx meta.mapping - source.jsx meta.sequence - source.jsx meta.string,
source.jsx meta.function,
source.ts - source.ts meta.mapping - source.ts meta.sequence - source.ts meta.string,
source.ts meta.function,
source.tsx - source.tsx meta.mapping - source.tsx meta.sequence - source.tsx meta.string,
source.tsx meta.function
source.js - source.js meta.string,
source.js meta.function - source.js meta.string,
source.jsx - source.jsx meta.string,
source.jsx meta.function - source.jsx meta.string,
source.ts - source.ts meta.string,
source.ts meta.function - source.ts meta.string,
source.tsx - source.tsx meta.string,
source.tsx meta.function - source.tsx meta.string
</string>
<key>settings</key>
<dict>
Expand Down

0 comments on commit dfad440

Please sign in to comment.