Skip to content

Commit

Permalink
Fix additional URI conversion problems for background thread (#6683)
Browse files Browse the repository at this point in the history
Fixes additional `Uri` conversion problems for the background thread, specifically `DiagnosticRelatedInfo`, which was missed in #6678 after the implementation of the `Uri` class (#6519).
  • Loading branch information
insilications authored Dec 8, 2023
1 parent a2e462e commit 5dd7564
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/pyright-internal/src/backgroundAnalysisBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,11 @@ export abstract class BackgroundAnalysisRunnerBase extends BackgroundThreadBase
const postableResults = {
...result,
diagnostics: result.diagnostics.map((d) => {
return { ...d, fileUri: JSON.parse(JSON.stringify(d.fileUri)) };
return {
...d,
fileUri: JSON.parse(JSON.stringify(d.fileUri)),
diagnostics: convertDiagnostics(d.diagnostics),
};
}),
};
port.postMessage({ requestType: 'analysisResult', data: postableResults });
Expand Down Expand Up @@ -719,7 +723,7 @@ function convertDiagnostics(diagnostics: Diagnostic[]) {

if (d._relatedInfo) {
for (const info of d._relatedInfo) {
diag.addRelatedInfo(info.message, info.fileUri, info.range);
diag.addRelatedInfo(info.message, JSON.parse(JSON.stringify(info.uri)), info.range);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/pyright-internal/src/languageServerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1566,10 +1566,10 @@ export abstract class LanguageServerBase implements LanguageServerInterface, Dis
const relatedInfo = diag.getRelatedInfo();
if (relatedInfo.length > 0) {
vsDiag.relatedInformation = relatedInfo
.filter((info) => this.canNavigateToFile(info.uri, fs))
.filter((info) => this.canNavigateToFile(Uri.fromJsonObj(info.uri), fs))
.map((info) =>
DiagnosticRelatedInformation.create(
Location.create(info.uri.toString(), info.range),
Location.create(Uri.fromJsonObj(info.uri).toString(), info.range),
info.message
)
);
Expand Down

0 comments on commit 5dd7564

Please sign in to comment.