Skip to content

Fix theme-aware constant highlighting - #4485

Open
WilliamK112 wants to merge 1 commit into
facebook:mainfrom
WilliamK112:fix/theme-aware-constant-highlighting
Open

Fix theme-aware constant highlighting#4485
WilliamK112 wants to merge 1 commit into
facebook:mainfrom
WilliamK112:fix/theme-aware-constant-highlighting

Conversation

@WilliamK112

@WilliamK112 WilliamK112 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove the hard-coded Dark+ foreground color for readonly-variable semantic tokens
  • retain a color-neutral bold rule so all-caps constants remain visually distinct across themes
  • keep the existing variable.other.constant.python TextMate scope fallback

This lets the active VS Code theme choose the constant color while preserving the visual distinction added for #1780. Light Modern and Dark Modern were both verified in isolated Extension Development Host profiles; screenshots and details are included in the review thread.

Fixes #4473

Validation

  • npm run package
  • repository formatting/lint command from AGENTS.md
  • JSON assertion that the readonly-variable rule is color-neutral and bold
  • live Light Modern and Dark Modern extension-host checks against a locally built Pyrefly LSP
  • git diff --check

AI disclosure

I used an AI coding assistant to help inspect the extension configuration, implement the change, and validate the result. I manually reviewed the final diff and visual evidence.

@meta-cla meta-cla Bot added the cla signed label Aug 9, 2026
@WilliamK112
WilliamK112 marked this pull request as ready for review August 9, 2026 12:42
@meta-codesync

meta-codesync Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D115356762. (Because this pull request was imported automatically, there will not be any future comments.)

@yangdanny97 yangdanny97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@yangdanny97

Copy link
Copy Markdown
Contributor

@WilliamK112 can you confirm that #1780 is still fixed after your change? since this effectively reverts part of the original fix for that.

screenshots of light and dark themes would be useful evidence, the current test plan is insufficient for this change, since this is not covered by automated testing.

@yangdanny97 yangdanny97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see other comment

The extension-level semantic token override forced constants to use a VS Code Dark+ color in every theme. Keep the TextMate scope fallback so active themes can choose an appropriate constant color.
@WilliamK112
WilliamK112 force-pushed the fix/theme-aware-constant-highlighting branch from b8479f7 to d1761ae Compare August 12, 2026 03:39
@github-actions github-actions Bot added size/xs and removed size/xs labels Aug 12, 2026
@WilliamK112

WilliamK112 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for flagging #1780. The first live check showed that simply removing the override was not sufficient: Dark Modern still distinguished constants via the retained variable.other.constant.python scope, but Light Modern did not. I adjusted the PR so the extension now applies only bold: true to variable.readonly:python, without setting a foreground color.

That preserves #1780's visual distinction in themes that do not assign constants a separate color, while #4473 remains fixed because each active theme still controls the actual color.

Light Modern

Light Modern: ALL_CAPS constants are bold and theme-colored

Dark Modern

Dark Modern: ALL_CAPS constants retain the theme's blue and are bold

Both screenshots are from isolated VS Code Extension Development Host profiles running this PR's extension against a locally built Pyrefly LSP. The logs confirm textDocument/semanticTokens/full completed and the sample file had zero diagnostics.

Validation on head d1761ae48:

  • npm run package
  • repository formatting/lint command from AGENTS.md
  • JSON assertion for the color-neutral bold rule
  • git diff --check

@yangdanny97

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

All caps variables are highlighted in teal regardless of theme

3 participants