From e1e0a265e931637f452ac05bb7d912e07bcee574 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 10:11:56 +0330 Subject: lsp: borrow errors ranged on the use, with related information for where the owner ended and was declared; vscode client passes relatedInformation through --- editors/vscode/client/extension.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'editors/vscode/client') diff --git a/editors/vscode/client/extension.js b/editors/vscode/client/extension.js index cd497d8..38c4c73 100644 --- a/editors/vscode/client/extension.js +++ b/editors/vscode/client/extension.js @@ -207,6 +207,13 @@ function showDiags(uri, raw) { : vscode.DiagnosticSeverity.Error; const diag = new vscode.Diagnostic(new vscode.Range(r.start.line, r.start.character, r.end.line, r.end.character), d.message, sev); diag.source = d.source || 'zc'; + // a borrow error names its owner: where it ended and where it was declared + if (Array.isArray(d.relatedInformation)) { + diag.relatedInformation = d.relatedInformation.filter(ri => ri && ri.location && ri.location.range).map(ri => { + const lr = ri.location.range; + return new vscode.DiagnosticRelatedInformation(new vscode.Location(vscode.Uri.parse(ri.location.uri || uri), new vscode.Range(lr.start.line, lr.start.character, lr.end.line, lr.end.character)), ri.message || ''); + }); + } return diag; }); stats.diagnostics += list.length; -- cgit v1.2.3