feat: add cssPeek.peekVariables toggle (#143)#161
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a cssPeek.peekVariables setting (default true) that allows users to filter out preprocessor variable definitions (SymbolKind.Variable) from peek/go-to-definition and workspace symbol results, addressing issue #143.
Changes:
- Declares the new
cssPeek.peekVariablesboolean configuration inpackage.jsonand extends theSettingsinterface/defaults in the server. - Plumbs the setting through
connection.onDefinitionandconnection.onWorkspaceSymbol(the latter is nowasyncto fetch configuration). - Extends
findSymbols/findDefinitionwith an options bag that skipsSymbolKind.Variableentries whenpeekVariablesisfalse.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| package.json | Adds the new cssPeek.peekVariables contribution config. |
| server/src/server.ts | Extends Settings and forwards the option to findDefinition/findSymbols; makes onWorkspaceSymbol async to read config. |
| server/src/core/findDefinition.ts | Adds options.peekVariables (default true) and skips SymbolKind.Variable symbols when off. |
| tests/src/findDefinition.test.ts | Adds tests for the new toggle and a regression check for non-variable symbols. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds a `cssPeek.peekVariables` setting (default `true`) that lets users hide preprocessor variable definitions (SCSS `$foo`, LESS `@foo`) from peek/go-to-definition results. Wires the setting through the LSP config flow and filters `SymbolKind.Variable` in `findSymbols` when disabled. Closes #143 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9beafb7 to
e6746c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
cssPeek.peekVariablessetting (boolean, defaulttrue) that lets users hide preprocessor variable definitions from peek / go-to-definition results.package.jsonundercontributes.configuration.Settingsinterface and default settings inserver/src/server.tsextended.connection.onDefinitionandconnection.onWorkspaceSymbolviagetDocumentSettings/connection.workspace.getConfiguration.findSymbolsaccepts an{ peekVariables?: boolean }options bag (defaulttrue) and skipsSymbolKind.Variableentries when off.findDefinitionforwards the option.Closes #143
Findings about current variable behavior
I verified what
vscode-css-languageservicereturns fromfindDocumentSymbols:$primary: red;SymbolKind.Variablewith name$primary@primary: red;SymbolKind.Variablewith name@primary:root { --primary: red; }:rootselector is)In practice, with the current selector regex in
findSymbols, preprocessor variables are not surfaced today because the class/id/tag patterns require the name to begin with.,#, or a word-boundary on the bare identifier —$primary/@primarynever match. I confirmed this with a probe againstfindSymbolsdirectly.So this PR is mostly defensive: it adds the setting and the filter so that
$/@), or--foo),variables will be filtered correctly when
cssPeek.peekVariables=false.Test plan
yarn build— passes with zero TS errorsyarn test— 26 tests pass (3 new assertions for the toggle: on, default-on, off, plus a regression check that non-variable symbols are unaffected)yarn lint— cleanyarn prettier— clean on changed filesThe new tests inject a synthetic
SymbolKind.Variableinto the cached symbol map (whose name would normally match a class regex) to exercise the filter in isolation from the language service's name encoding.