From d84912483dcdf568d8abd1c11832661758412f00 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 20 Mar 2021 13:44:12 +0100 Subject: Fix add_life_to_type label typo --- crates/ide_assists/src/handlers/add_lifetime_to_type.rs | 5 ++--- crates/ide_assists/src/handlers/add_turbo_fish.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/ide_assists/src/handlers/add_lifetime_to_type.rs b/crates/ide_assists/src/handlers/add_lifetime_to_type.rs index 2edf7b204..844928754 100644 --- a/crates/ide_assists/src/handlers/add_lifetime_to_type.rs +++ b/crates/ide_assists/src/handlers/add_lifetime_to_type.rs @@ -29,8 +29,7 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op let node = ctx.find_node_at_offset::()?; let has_lifetime = node .generic_param_list() - .map(|gen_list| gen_list.lifetime_params().count() > 0) - .unwrap_or_default(); + .map_or(false, |gen_list| gen_list.lifetime_params().next().is_some()); if has_lifetime { return None; @@ -41,7 +40,7 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op acc.add( AssistId("add_lifetime_to_type", AssistKind::Generate), - "Add lifetime`", + "Add lifetime", target, |builder| { match node.generic_param_list() { diff --git a/crates/ide_assists/src/handlers/add_turbo_fish.rs b/crates/ide_assists/src/handlers/add_turbo_fish.rs index 436767895..e4bb61c4e 100644 --- a/crates/ide_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ide_assists/src/handlers/add_turbo_fish.rs @@ -26,7 +26,7 @@ use crate::{ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| { let arg_list = ctx.find_node_at_offset::()?; - if arg_list.args().count() > 0 { + if arg_list.args().next().is_some() { return None; } cov_mark::hit!(add_turbo_fish_after_call); -- cgit v1.2.3 From a9a7c5cb1f76f6d446e24a6867d404a62e60d8e2 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 20 Mar 2021 13:44:39 +0100 Subject: Don't return a SourceChange on WillRenameFiles when nothing gets refactored --- crates/rust-analyzer/src/handlers.rs | 7 +++++-- crates/rust-analyzer/tests/rust-analyzer/main.rs | 8 ++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index b6f484e51..880fea622 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -465,8 +465,11 @@ pub(crate) fn handle_will_rename_files( source_change.file_system_edits.clear(); // no collect here because we want to merge text edits on same file ids source_change.extend(source_changes.map(|it| it.source_file_edits).flatten()); - let workspace_edit = to_proto::workspace_edit(&snap, source_change)?; - Ok(Some(workspace_edit)) + if source_change.source_file_edits.is_empty() { + Ok(None) + } else { + to_proto::workspace_edit(&snap, source_change).map(Some) + } } pub(crate) fn handle_goto_definition( diff --git a/crates/rust-analyzer/tests/rust-analyzer/main.rs b/crates/rust-analyzer/tests/rust-analyzer/main.rs index 7545b4a34..19516de7b 100644 --- a/crates/rust-analyzer/tests/rust-analyzer/main.rs +++ b/crates/rust-analyzer/tests/rust-analyzer/main.rs @@ -838,9 +838,7 @@ fn main() {} new_uri: base_path.join("src/from_mod/foo.rs").to_str().unwrap().to_string(), }], }, - json!({ - "documentChanges": [] - }), + json!(null), ); //rename file from foo.rs to mod.rs @@ -851,9 +849,7 @@ fn main() {} new_uri: base_path.join("src/to_mod/mod.rs").to_str().unwrap().to_string(), }], }, - json!({ - "documentChanges": [] - }), + json!(null), ); //rename same level file -- cgit v1.2.3