From 6c379b9f4bb9774758e018944a33db5eb29622fb Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 27 Jul 2022 12:45:29 +0200 Subject: [PATCH] fix: Fix Semantics::original_ast_node not caching the resulting file --- crates/hir/src/semantics.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index fc8f23f19ab..a75e5cafd0b 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -924,7 +924,12 @@ fn original_range_opt(&self, node: &SyntaxNode) -> Option { } fn original_ast_node(&self, node: N) -> Option { - self.wrap_node_infile(node).original_ast_node(self.db.upcast()).map(|it| it.value) + self.wrap_node_infile(node).original_ast_node(self.db.upcast()).map( + |InFile { file_id, value }| { + self.cache(find_root(value.syntax()), file_id); + value + }, + ) } fn diagnostics_display_range(&self, src: InFile) -> FileRange {