Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/typing.rs')
-rw-r--r--crates/ide/src/typing.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/ide/src/typing.rs b/crates/ide/src/typing.rs
index 0381865fed..f8b0dbfe62 100644
--- a/crates/ide/src/typing.rs
+++ b/crates/ide/src/typing.rs
@@ -17,7 +17,10 @@ mod on_enter;
use either::Either;
use hir::EditionedFileId;
-use ide_db::{FilePosition, RootDatabase, base_db::RootQueryDb};
+use ide_db::{
+ FilePosition, RootDatabase,
+ base_db::{RootQueryDb, SourceDatabase},
+};
use span::Edition;
use std::iter;
@@ -70,11 +73,12 @@ pub(crate) fn on_char_typed(
if !TRIGGER_CHARS.contains(&char_typed) {
return None;
}
- // FIXME: We need to figure out the edition of the file here, but that means hitting the
- // database for more than just parsing the file which is bad.
+ let edition = db
+ .source_root_crates(db.file_source_root(position.file_id).source_root_id(db))
+ .first()
+ .map_or(Edition::CURRENT, |crates| crates.data(db).edition);
// FIXME: We are hitting the database here, if we are unlucky this call might block momentarily
- // causing the editor to feel sluggish!
- let edition = Edition::CURRENT_FIXME;
+ // causing the editor to feel sluggish! We need to make this bail if it would block too long?
let editioned_file_id_wrapper = EditionedFileId::from_span_guess_origin(
db,
span::EditionedFileId::new(position.file_id, edition),
@@ -457,8 +461,8 @@ mod tests {
let (offset, mut before) = extract_offset(before);
let edit = TextEdit::insert(offset, char_typed.to_string());
edit.apply(&mut before);
- let parse = SourceFile::parse(&before, span::Edition::CURRENT_FIXME);
- on_char_typed_(&parse, offset, char_typed, span::Edition::CURRENT_FIXME).map(|it| {
+ let parse = SourceFile::parse(&before, span::Edition::CURRENT);
+ on_char_typed_(&parse, offset, char_typed, span::Edition::CURRENT).map(|it| {
it.apply(&mut before);
before.to_string()
})