From 74780a15f65916d08942eb53c43b8e8c0b62cb48 Mon Sep 17 00:00:00 2001 From: Timo Freiberg Date: Mon, 20 Apr 2020 18:02:36 +0200 Subject: Jump to sourceChanges in other files --- crates/ra_assists/src/handlers/add_function.rs | 13 ++----------- crates/ra_assists/src/lib.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs index b65ded871..9bd46f5dc 100644 --- a/crates/ra_assists/src/handlers/add_function.rs +++ b/crates/ra_assists/src/handlers/add_function.rs @@ -907,23 +907,14 @@ mod foo; fn main() { foo::bar<|>() } - //- /foo.rs - ", r" -//- /main.rs -mod foo; -fn main() { - foo::bar() -} -//- /foo.rs -fn bar() { +pub(crate) fn bar() { <|>todo!() -} -", +}", ) } diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index fb57486cb..ccc95735f 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -197,7 +197,7 @@ mod helpers { use ra_ide_db::{symbol_index::SymbolsDatabase, RootDatabase}; use test_utils::{add_cursor, assert_eq_text, extract_range_or_offset, RangeOrOffset}; - use crate::{AssistCtx, AssistHandler}; + use crate::{AssistCtx, AssistFile, AssistHandler}; use hir::Semantics; pub(crate) fn with_single_file(text: &str) -> (RootDatabase, FileId) { @@ -259,7 +259,13 @@ mod helpers { (Some(assist), ExpectedResult::After(after)) => { let action = assist.0[0].action.clone().unwrap(); - let mut actual = action.edit.apply(&text_without_caret); + let assisted_file_text = if let AssistFile::TargetFile(file_id) = action.file { + db.file_text(file_id).as_ref().to_owned() + } else { + text_without_caret + }; + + let mut actual = action.edit.apply(&assisted_file_text); match action.cursor_position { None => { if let RangeOrOffset::Offset(before_cursor_pos) = range_or_offset { -- cgit v1.2.3