Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/ide-assists/src/handlers/convert_integer_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;");
}
}
2 changes: 0 additions & 2 deletions crates/ide-assists/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,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
"#]]
Expand Down Expand Up @@ -489,7 +488,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
"#]]
Expand Down
Loading