Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/inlay_hints/extern_block.rs')
-rw-r--r--crates/ide/src/inlay_hints/extern_block.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/crates/ide/src/inlay_hints/extern_block.rs b/crates/ide/src/inlay_hints/extern_block.rs
index 4cc4925cda..2bc91b68ed 100644
--- a/crates/ide/src/inlay_hints/extern_block.rs
+++ b/crates/ide/src/inlay_hints/extern_block.rs
@@ -8,7 +8,7 @@ use crate::{InlayHint, InlayHintsConfig};
pub(super) fn extern_block_hints(
acc: &mut Vec<InlayHint>,
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
- _config: &InlayHintsConfig,
+ config: &InlayHintsConfig,
_file_id: EditionedFileId,
extern_block: ast::ExternBlock,
) -> Option<()> {
@@ -23,7 +23,9 @@ pub(super) fn extern_block_hints(
pad_right: true,
kind: crate::InlayKind::ExternUnsafety,
label: crate::InlayHintLabel::from("unsafe"),
- text_edit: Some(TextEdit::insert(abi.syntax().text_range().start(), "unsafe ".to_owned())),
+ text_edit: Some(config.lazy_text_edit(|| {
+ TextEdit::insert(abi.syntax().text_range().start(), "unsafe ".to_owned())
+ })),
resolve_parent: Some(extern_block.syntax().text_range()),
});
Some(())
@@ -32,7 +34,7 @@ pub(super) fn extern_block_hints(
pub(super) fn fn_hints(
acc: &mut Vec<InlayHint>,
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
- _config: &InlayHintsConfig,
+ config: &InlayHintsConfig,
_file_id: EditionedFileId,
fn_: &ast::Fn,
extern_block: &ast::ExternBlock,
@@ -42,14 +44,14 @@ pub(super) fn fn_hints(
return None;
}
let fn_ = fn_.fn_token()?;
- acc.push(item_hint(extern_block, fn_));
+ acc.push(item_hint(config, extern_block, fn_));
Some(())
}
pub(super) fn static_hints(
acc: &mut Vec<InlayHint>,
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
- _config: &InlayHintsConfig,
+ config: &InlayHintsConfig,
_file_id: EditionedFileId,
static_: &ast::Static,
extern_block: &ast::ExternBlock,
@@ -59,11 +61,15 @@ pub(super) fn static_hints(
return None;
}
let static_ = static_.static_token()?;
- acc.push(item_hint(extern_block, static_));
+ acc.push(item_hint(config, extern_block, static_));
Some(())
}
-fn item_hint(extern_block: &ast::ExternBlock, token: SyntaxToken) -> InlayHint {
+fn item_hint(
+ config: &InlayHintsConfig,
+ extern_block: &ast::ExternBlock,
+ token: SyntaxToken,
+) -> InlayHint {
InlayHint {
range: token.text_range(),
position: crate::InlayHintPosition::Before,
@@ -71,7 +77,7 @@ fn item_hint(extern_block: &ast::ExternBlock, token: SyntaxToken) -> InlayHint {
pad_right: true,
kind: crate::InlayKind::ExternUnsafety,
label: crate::InlayHintLabel::from("unsafe"),
- text_edit: {
+ text_edit: Some(config.lazy_text_edit(|| {
let mut builder = TextEdit::builder();
builder.insert(token.text_range().start(), "unsafe ".to_owned());
if extern_block.unsafe_token().is_none() {
@@ -79,8 +85,8 @@ fn item_hint(extern_block: &ast::ExternBlock, token: SyntaxToken) -> InlayHint {
builder.insert(abi.syntax().text_range().start(), "unsafe ".to_owned());
}
}
- Some(builder.finish())
- },
+ builder.finish()
+ })),
resolve_parent: Some(extern_block.syntax().text_range()),
}
}