Skip to content

Commit eec1381

Browse files
committed
Fix find references
1 parent e03bdce commit eec1381

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pkgs/sass_language_server/lib/src/language_server.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class LanguageServer {
8585
connection: _connection,
8686
onDidChangeContent: (params) async {
8787
try {
88-
_ls.cache.remove(params.document.uri);
88+
// Reparse the stylesheet to update the cache with the new
89+
// version of the document.
90+
_ls.parseStylesheet(params.document);
8991
if (initialScan != null) {
9092
await initialScan;
9193
}

pkgs/sass_language_services/lib/src/features/find_references/find_references_feature.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@ class FindReferencesFeature extends GoToDefinitionFeature {
5454

5555
var name = builtin ?? definition.name;
5656

57-
var candidates = <Reference>[];
57+
var documents = ls.cache.getDocuments();
5858
// Go through all documents with a visitor.
5959
// For each document, collect candidates that match the definition name.
60-
for (var document in ls.cache.getDocuments()) {
60+
for (var document in documents) {
6161
var stylesheet = ls.parseStylesheet(document);
6262
var visitor = FindReferencesVisitor(
6363
document,
6464
name,
6565
includeDeclaration: context.includeDeclaration,
6666
);
6767
stylesheet.accept(visitor);
68-
candidates.addAll(visitor.candidates);
6968

7069
// Go through all candidates and add matches to references.
7170
// A match is a candidate with the same name, referenceKind,
7271
// and whose definition is the same as the definition of the
7372
// symbol at [position].
73+
var candidates = visitor.candidates;
7474
for (var candidate in candidates) {
7575
if (builtin case var name?) {
7676
if (name.contains(candidate.name)) {
@@ -105,7 +105,7 @@ class FindReferencesFeature extends GoToDefinitionFeature {
105105
// the two definitions are the same, we have a reference.
106106
var candidateDefinition = await internalGoToDefinition(
107107
document,
108-
position,
108+
candidate.location.range.start,
109109
);
110110

111111
if (candidateDefinition != null &&
@@ -117,6 +117,8 @@ class FindReferencesFeature extends GoToDefinitionFeature {
117117
references.add(candidate);
118118
continue;
119119
}
120+
} else {
121+
continue;
120122
}
121123
}
122124
}

0 commit comments

Comments
 (0)