mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +00:00
feat: update insta inline snapshot when clicks 'Update Test' runnable
This commit is contained in:
parent
88fbdcd510
commit
03c24d7c28
@ -104,7 +104,7 @@ pub use crate::{
|
||||
navigation_target::{NavigationTarget, TryToNav, UpmappingResult},
|
||||
references::ReferenceSearchResult,
|
||||
rename::RenameError,
|
||||
runnables::{Runnable, RunnableKind, TestId},
|
||||
runnables::{Runnable, RunnableKind, TestId, UpdateTest},
|
||||
signature_help::SignatureHelp,
|
||||
static_index::{
|
||||
StaticIndex, StaticIndexedFile, TokenId, TokenStaticData, VendoredLibrariesConfig,
|
||||
|
@ -941,9 +941,7 @@ pub(crate) fn handle_runnables(
|
||||
|
||||
let update_test = runnable.update_test;
|
||||
if let Some(mut runnable) = to_proto::runnable(&snap, runnable)? {
|
||||
if let Some(runnable) =
|
||||
to_proto::make_update_runnable(&runnable, &update_test.label(), &update_test.env())
|
||||
{
|
||||
if let Some(runnable) = to_proto::make_update_runnable(&runnable, update_test) {
|
||||
res.push(runnable);
|
||||
}
|
||||
|
||||
@ -2158,7 +2156,7 @@ fn runnable_action_links(
|
||||
|
||||
if hover_actions_config.update_test && client_commands_config.run_single {
|
||||
let label = update_test.label();
|
||||
if let Some(r) = to_proto::make_update_runnable(&r, &label, &update_test.env()) {
|
||||
if let Some(r) = to_proto::make_update_runnable(&r, update_test) {
|
||||
let update_command = to_proto::command::run_single(&r, label.unwrap().as_str());
|
||||
group.commands.push(to_command_link(update_command, r.label.clone()));
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ use ide::{
|
||||
InlayFieldsToResolve, InlayHint, InlayHintLabel, InlayHintLabelPart, InlayKind, LazyProperty,
|
||||
Markup, NavigationTarget, ReferenceCategory, RenameError, Runnable, Severity, SignatureHelp,
|
||||
SnippetEdit, SourceChange, StructureNodeKind, SymbolKind, TextEdit, TextRange, TextSize,
|
||||
UpdateTest,
|
||||
};
|
||||
use ide_db::{assists, rust_doc::format_docs, FxHasher};
|
||||
use itertools::Itertools;
|
||||
use paths::{Utf8Component, Utf8Prefix};
|
||||
use semver::VersionReq;
|
||||
use serde_json::to_value;
|
||||
use syntax::SmolStr;
|
||||
use vfs::AbsPath;
|
||||
|
||||
use crate::{
|
||||
@ -1623,8 +1623,7 @@ pub(crate) fn code_lens(
|
||||
}
|
||||
if lens_config.update_test && client_commands_config.run_single {
|
||||
let label = update_test.label();
|
||||
let env = update_test.env();
|
||||
if let Some(r) = make_update_runnable(&r, &label, &env) {
|
||||
if let Some(r) = make_update_runnable(&r, update_test) {
|
||||
let command = command::run_single(&r, label.unwrap().as_str());
|
||||
acc.push(lsp_types::CodeLens {
|
||||
range: annotation_range,
|
||||
@ -1871,22 +1870,22 @@ pub(crate) mod command {
|
||||
|
||||
pub(crate) fn make_update_runnable(
|
||||
runnable: &lsp_ext::Runnable,
|
||||
label: &Option<SmolStr>,
|
||||
env: &[(&str, &str)],
|
||||
update_test: UpdateTest,
|
||||
) -> Option<lsp_ext::Runnable> {
|
||||
if !matches!(runnable.args, lsp_ext::RunnableArgs::Cargo(_)) {
|
||||
return None;
|
||||
}
|
||||
let label = label.as_ref()?;
|
||||
let label = update_test.label()?;
|
||||
|
||||
let mut runnable = runnable.clone();
|
||||
runnable.label = format!("{} + {}", runnable.label, label);
|
||||
|
||||
let lsp_ext::RunnableArgs::Cargo(r) = &mut runnable.args else {
|
||||
unreachable!();
|
||||
return None;
|
||||
};
|
||||
|
||||
r.environment.extend(env.iter().map(|(k, v)| (k.to_string(), v.to_string())));
|
||||
r.environment.extend(update_test.env().iter().map(|(k, v)| (k.to_string(), v.to_string())));
|
||||
|
||||
if update_test.insta {
|
||||
r.cargo_args.insert(0, "insta".to_string());
|
||||
}
|
||||
|
||||
Some(runnable)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user