mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 18:53:39 +00:00
Jump to sourceChanges in other files
This commit is contained in:
parent
ba8faf3efc
commit
74780a15f6
@ -907,23 +907,14 @@ mod foo;
|
|||||||
fn main() {
|
fn main() {
|
||||||
foo::bar<|>()
|
foo::bar<|>()
|
||||||
}
|
}
|
||||||
|
|
||||||
//- /foo.rs
|
//- /foo.rs
|
||||||
|
|
||||||
",
|
",
|
||||||
r"
|
r"
|
||||||
//- /main.rs
|
|
||||||
mod foo;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
foo::bar()
|
|
||||||
}
|
|
||||||
|
|
||||||
//- /foo.rs
|
pub(crate) fn bar() {
|
||||||
fn bar() {
|
|
||||||
<|>todo!()
|
<|>todo!()
|
||||||
}
|
}",
|
||||||
",
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ mod helpers {
|
|||||||
use ra_ide_db::{symbol_index::SymbolsDatabase, RootDatabase};
|
use ra_ide_db::{symbol_index::SymbolsDatabase, RootDatabase};
|
||||||
use test_utils::{add_cursor, assert_eq_text, extract_range_or_offset, RangeOrOffset};
|
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;
|
use hir::Semantics;
|
||||||
|
|
||||||
pub(crate) fn with_single_file(text: &str) -> (RootDatabase, FileId) {
|
pub(crate) fn with_single_file(text: &str) -> (RootDatabase, FileId) {
|
||||||
@ -259,7 +259,13 @@ mod helpers {
|
|||||||
(Some(assist), ExpectedResult::After(after)) => {
|
(Some(assist), ExpectedResult::After(after)) => {
|
||||||
let action = assist.0[0].action.clone().unwrap();
|
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 {
|
match action.cursor_position {
|
||||||
None => {
|
None => {
|
||||||
if let RangeOrOffset::Offset(before_cursor_pos) = range_or_offset {
|
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,
|
toReveal.position,
|
||||||
);
|
);
|
||||||
const editor = vscode.window.activeTextEditor;
|
const editor = vscode.window.activeTextEditor;
|
||||||
if (!editor || editor.document.uri.toString() !== uri.toString()) {
|
if (!editor || !editor.selection.isEmpty) {
|
||||||
return;
|
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.selection = new vscode.Selection(position, position);
|
||||||
editor.revealRange(
|
editor.revealRange(
|
||||||
|
Loading…
Reference in New Issue
Block a user