Skip to content

Commit 1485a88

Browse files
authored
Merge pull request #18920 from Veykril/push-zxwtmooxumsl
fix: Fix `ref` text edit for binding mode hints
2 parents 9923b00 + 720e727 commit 1485a88

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

crates/ide/src/inlay_hints/binding_mode.rs

+27-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub(super) fn hints(
106106
InlayHintPosition::Before => h.range.start(),
107107
InlayHintPosition::After => h.range.end(),
108108
},
109-
h.label.parts.iter().map(|p| &*p.text).collect(),
109+
h.label.parts.iter().map(|p| &*p.text).chain(h.pad_right.then_some(" ")).collect(),
110110
);
111111
}
112112
let edit = edit.finish();
@@ -118,8 +118,10 @@ pub(super) fn hints(
118118

119119
#[cfg(test)]
120120
mod tests {
121+
use expect_test::expect;
122+
121123
use crate::{
122-
inlay_hints::tests::{check_with_config, DISABLED_CONFIG},
124+
inlay_hints::tests::{check_edit, check_with_config, DISABLED_CONFIG},
123125
InlayHintsConfig,
124126
};
125127

@@ -194,4 +196,27 @@ fn foo(s @ Struct { field, .. }: &Struct) {}
194196
"#,
195197
);
196198
}
199+
200+
#[test]
201+
fn edits() {
202+
check_edit(
203+
InlayHintsConfig { binding_mode_hints: true, ..DISABLED_CONFIG },
204+
r#"
205+
fn main() {
206+
match &(0,) {
207+
(x,) | (x,) => (),
208+
((x,) | (x,)) => (),
209+
}
210+
}
211+
"#,
212+
expect![[r#"
213+
fn main() {
214+
match &(0,) {
215+
&(&((ref x,) | (ref x,))) => (),
216+
&((ref x,) | (ref x,)) => (),
217+
}
218+
}
219+
"#]],
220+
);
221+
}
197222
}

0 commit comments

Comments
 (0)