Skip to content

Commit

Permalink
fix: Fix ref text edit for binding mode hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Jan 12, 2025
1 parent 9923b00 commit 720e727
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions crates/ide/src/inlay_hints/binding_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub(super) fn hints(
InlayHintPosition::Before => h.range.start(),
InlayHintPosition::After => h.range.end(),
},
h.label.parts.iter().map(|p| &*p.text).collect(),
h.label.parts.iter().map(|p| &*p.text).chain(h.pad_right.then_some(" ")).collect(),
);
}
let edit = edit.finish();
Expand All @@ -118,8 +118,10 @@ pub(super) fn hints(

#[cfg(test)]
mod tests {
use expect_test::expect;

use crate::{
inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
inlay_hints::tests::{check_edit, check_with_config, DISABLED_CONFIG},
InlayHintsConfig,
};

Expand Down Expand Up @@ -194,4 +196,27 @@ fn foo(s @ Struct { field, .. }: &Struct) {}
"#,
);
}

#[test]
fn edits() {
check_edit(
InlayHintsConfig { binding_mode_hints: true, ..DISABLED_CONFIG },
r#"
fn main() {
match &(0,) {
(x,) | (x,) => (),
((x,) | (x,)) => (),
}
}
"#,
expect![[r#"
fn main() {
match &(0,) {
&(&((ref x,) | (ref x,))) => (),
&((ref x,) | (ref x,)) => (),
}
}
"#]],
);
}
}

0 comments on commit 720e727

Please sign in to comment.