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

feat(core): lighter token explanation with scopeName #739

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

antfu
Copy link
Member

@antfu antfu commented Aug 12, 2024

fix #736

Copy link

netlify bot commented Aug 12, 2024

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit 5d62299
🔍 Latest deploy log https://app.netlify.com/sites/shiki-matsu/deploys/66bce535f7bf7900087d3a4b
😎 Deploy Preview https://deploy-preview-739--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Aug 12, 2024

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit 5d62299
🔍 Latest deploy log https://app.netlify.com/sites/shiki-next/deploys/66bce5359ea812000809cd87
😎 Deploy Preview https://deploy-preview-739--shiki-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.44%. Comparing base (933415c) to head (5d62299).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

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)

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

@antfu antfu changed the title feat: explanation scopeName feat(core): lighter token explanation with scopeName Aug 14, 2024
@antfu antfu merged commit efbb7fb into main Aug 14, 2024
9 of 11 checks passed
@antfu antfu deleted the feat/explanation-scope branch August 14, 2024 17:11
diegohaz referenced this pull request in ariakit/ariakit Aug 15, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](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) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/1.12.1/1.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/1.12.1/1.13.0?slim=true)](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
[@&#8203;antfu](https://togithub.com/antfu)
[<samp>(b68ee)</samp>](https://togithub.com/shikijs/shiki/commit/b68ee52f)
- **core**: Lighter token explanation with `scopeName`  -  by
[@&#8203;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
[@&#8203;Ovyerus](https://togithub.com/Ovyerus) and
[@&#8203;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>
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.

Option to exclude themeMatches from explanations
2 participants