mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Jump to sourceChanges in other files
This commit is contained in:
parent
ba8faf3efc
commit
74780a15f6
3 changed files with 15 additions and 16 deletions
|
@ -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!()
|
||||
}
|
||||
",
|
||||
}",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -37,11 +37,13 @@ export async function applySourceChange(ctx: Ctx, change: ra.SourceChange) {
|
|||
toReveal.position,
|
||||
);
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (!editor || editor.document.uri.toString() !== uri.toString()) {
|
||||
if (!editor || !editor.selection.isEmpty) {
|
||||
return;
|
||||
}
|
||||
if (!editor.selection.isEmpty) {
|
||||
return;
|
||||
|
||||
if (editor.document.uri !== uri) {
|
||||
const doc = await vscode.workspace.openTextDocument(uri);
|
||||
await vscode.window.showTextDocument(doc);
|
||||
}
|
||||
editor.selection = new vscode.Selection(position, position);
|
||||
editor.revealRange(
|
||||
|
|
Loading…
Reference in a new issue