about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorChayim Refael Friedman <chayimfr@gmail.com>2025-08-23 22:03:17 +0000
committerGitHub <noreply@github.com>2025-08-23 22:03:17 +0000
commita9973f6398c476557cb3b44355ae541513fe2bf1 (patch)
tree35a9c8ee52c022d241019b8b35d9195935450218 /src
parentcf358c09cebfe3e1c0d7145242396f6066033fad (diff)
parent3868f8ad5c2ef77fa823dc17da14ba13c2d508f7 (diff)
Merge pull request #20511 from A4-Tacks/fix-conv-int-lit-on-selected
convert_integer_literal not on selected
Diffstat (limited to 'src')
-rw-r--r--src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_integer_literal.rs8
-rw-r--r--src/tools/rust-analyzer/crates/ide-assists/src/tests.rs2
2 files changed, 8 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_integer_literal.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_integer_literal.rs
index 846f4e9b258..bc76ade97f6 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_integer_literal.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_integer_literal.rs
@@ -14,6 +14,9 @@ use crate::{AssistContext, AssistId, Assists, GroupLabel};
 // const _: i32 = 0b1010;
 // ```
 pub(crate) fn convert_integer_literal(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
+    if !ctx.has_empty_selection() {
+        return None;
+    }
     let literal = ctx.find_node_at_offset::<ast::Literal>()?;
     let literal = match literal.kind() {
         ast::LiteralKind::IntNumber(it) => it,
@@ -265,4 +268,9 @@ mod tests {
             111111111111111111111111111111111111111111111111111111111111111111111111$0;";
         check_assist_not_applicable(convert_integer_literal, before);
     }
+
+    #[test]
+    fn convert_non_empty_selection_literal() {
+        check_assist_not_applicable(convert_integer_literal, "const _: i32 = $00b1010$0;");
+    }
 }
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/tests.rs b/src/tools/rust-analyzer/crates/ide-assists/src/tests.rs
index c7c322a15e5..3e422ae1b8f 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/tests.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/tests.rs
@@ -469,7 +469,6 @@ pub fn test_some_range(a: int) -> bool {
     let expected = labels(&assists);
 
     expect![[r#"
-        Convert integer base
         Extract into...
         Replace if let with match
     "#]]
@@ -502,7 +501,6 @@ pub fn test_some_range(a: int) -> bool {
         let expected = labels(&assists);
 
         expect![[r#"
-            Convert integer base
             Extract into...
             Replace if let with match
         "#]]