Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3641,8 +3641,24 @@ module ts {
}
}

/// References and Occurrences
function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
let results = getOccurrencesAtPositionCore(fileName, position);

if (results) {
let sourceFile = getCanonicalFileName(normalizeSlashes(fileName));

// ensure the results are in the file we're interested in
results.forEach((value) => {
let targetFile = getCanonicalFileName(normalizeSlashes(value.fileName));
Debug.assert(sourceFile == targetFile, `Unexpected file in results. Found results in ${targetFile} expected only results in ${sourceFile}.`);
});
}

return results;
}

/// References and Occurrences
function getOccurrencesAtPositionCore(fileName: string, position: number): ReferenceEntry[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just filter instead. this is going to fail anyways. just remove the entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This won't crash VS, and I rather have this fixed in the script side to prevent we do unnecessary work there.

Copy link
Contributor

Choose a reason for hiding this comment

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

i meant to filter on the script side. you know the caller asked for a specific file, so just filter results that are not there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the idea is that we shouldn't be finding more results anyways. It represents a bug in our code that we should not be trying to workaround. Instead, we should track down the actual bug and fix it.

synchronizeHostData();

let sourceFile = getValidSourceFile(fileName);
Expand Down