-
-
Notifications
You must be signed in to change notification settings - Fork 414
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
feat(core): lighter token explanation with scopeName
#739
Conversation
✅ Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #739 +/- ##
==========================================
+ Coverage 94.42% 94.44% +0.01%
==========================================
Files 63 63
Lines 3804 3815 +11
Branches 839 842 +3
==========================================
+ Hits 3592 3603 +11
Misses 207 207
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if
starting on line 129 can be changed to
if (options.includeExplanation && options.includeExplanation !== 'scopeName') {
since the themeSettingsSelectors
do not end up being used in that case
@@ -236,14 +240,17 @@ function _tokenizeWithTheme( | |||
function explainThemeScopes( | |||
themeSelectors: ThemeSettingsSelectors[], | |||
scopes: string[], | |||
includeExplanation: TokenizeWithThemeOptions['includeExplanation'], | |||
): ThemedTokenScopeExplanation[] { | |||
const result: ThemedTokenScopeExplanation[] = [] | |||
for (let i = 0, len = scopes.length; i < len; i++) { | |||
const parentScopes = scopes.slice(0, i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parentScopes
is not needed if includeExplanation === 'scopeName'
, so the slice could be avoided. This doesn't have a big impact though; only a 1~2% savings in my tests, so not sure if it's worth the tradeoff in readability
scopeName
scopeName
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [shiki](https://togithub.com/shikijs/shiki) ([source](https://togithub.com/shikijs/shiki/tree/HEAD/packages/shiki)) | [`1.12.1` -> `1.13.0`](https://renovatebot.com/diffs/npm/shiki/1.12.1/1.13.0) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>shikijs/shiki (shiki)</summary> ### [`v1.13.0`](https://togithub.com/shikijs/shiki/releases/tag/v1.13.0) [Compare Source](https://togithub.com/shikijs/shiki/compare/v1.12.1...v1.13.0) ##### 🚀 Features - New grammar, new themes, update deps - by [@​antfu](https://togithub.com/antfu) [<samp>(b68ee)</samp>](https://togithub.com/shikijs/shiki/commit/b68ee52f) - **core**: Lighter token explanation with `scopeName` - by [@​antfu](https://togithub.com/antfu) in [https://github.com/shikijs/shiki/issues/739](https://togithub.com/shikijs/shiki/issues/739) [<samp>(efbb7)</samp>](https://togithub.com/shikijs/shiki/commit/efbb7fb4) - **rehype**: Trim trailing new line passed in from rehype/remark - by [@​Ovyerus](https://togithub.com/Ovyerus) and [@​antfu](https://togithub.com/antfu) in [https://github.com/shikijs/shiki/issues/729](https://togithub.com/shikijs/shiki/issues/729) [<samp>(aea7f)</samp>](https://togithub.com/shikijs/shiki/commit/aea7f9ea) ##### [View changes on GitHub](https://togithub.com/shikijs/shiki/compare/v1.12.1...v1.13.0) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [x] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/ariakit/ariakit). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
fix #736