Merge pull request #20511 from A4-Tacks/fix-conv-int-lit-on-selected

convert_integer_literal not on selected
This commit is contained in:
Chayim Refael Friedman 2025-08-23 22:03:17 +00:00 committed by GitHub
commit 413ed5a361
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -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;");
}
}

View File

@ -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
"#]]