Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/syntax_highlighting.rs')
-rw-r--r--crates/ide/src/syntax_highlighting.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index fd8e6f4046..2318592005 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -15,6 +15,7 @@ mod tests;
use hir::{DescendPreference, Name, Semantics};
use ide_db::{FxHashMap, RootDatabase, SymbolKind};
+use span::EditionedFileId;
use syntax::{
ast::{self, IsString},
AstNode, AstToken, NodeOrToken,
@@ -188,11 +189,14 @@ pub(crate) fn highlight(
) -> Vec<HlRange> {
let _p = tracing::info_span!("highlight").entered();
let sema = Semantics::new(db);
+ let file_id = sema
+ .attach_first_edition(file_id)
+ .unwrap_or_else(|| EditionedFileId::current_edition(file_id));
// Determine the root based on the given range.
let (root, range_to_highlight) = {
- let source_file = sema.parse(file_id);
- let source_file = source_file.syntax();
+ let file = sema.parse(file_id);
+ let source_file = file.syntax();
match range_to_highlight {
Some(range) => {
let node = match source_file.covering_element(range) {
@@ -218,7 +222,7 @@ fn traverse(
hl: &mut Highlights,
sema: &Semantics<'_, RootDatabase>,
config: HighlightConfig,
- file_id: FileId,
+ file_id: EditionedFileId,
root: &SyntaxNode,
krate: hir::Crate,
range_to_highlight: TextRange,