Skip to content

Commit 413ed5a

Browse files
Merge pull request #20511 from A4-Tacks/fix-conv-int-lit-on-selected
convert_integer_literal not on selected
2 parents e6cd085 + 5f8cfeb commit 413ed5a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

crates/ide-assists/src/handlers/convert_integer_literal.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ use crate::{AssistContext, AssistId, Assists, GroupLabel};
1414
// const _: i32 = 0b1010;
1515
// ```
1616
pub(crate) fn convert_integer_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
17+
if !ctx.has_empty_selection() {
18+
return None;
19+
}
1720
let literal = ctx.find_node_at_offset::<ast::Literal>()?;
1821
let literal = match literal.kind() {
1922
ast::LiteralKind::IntNumber(it) => it,
@@ -265,4 +268,9 @@ mod tests {
265268
111111111111111111111111111111111111111111111111111111111111111111111111$0;";
266269
check_assist_not_applicable(convert_integer_literal, before);
267270
}
271+
272+
#[test]
273+
fn convert_non_empty_selection_literal() {
274+
check_assist_not_applicable(convert_integer_literal, "const _: i32 = $00b1010$0;");
275+
}
268276
}

crates/ide-assists/src/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ pub fn test_some_range(a: int) -> bool {
469469
let expected = labels(&assists);
470470

471471
expect![[r#"
472-
Convert integer base
473472
Extract into...
474473
Replace if let with match
475474
"#]]
@@ -502,7 +501,6 @@ pub fn test_some_range(a: int) -> bool {
502501
let expected = labels(&assists);
503502

504503
expect![[r#"
505-
Convert integer base
506504
Extract into...
507505
Replace if let with match
508506
"#]]

0 commit comments

Comments
 (0)