return immediately from render_tuple_lit
if snippet_cap
is None
partially addresses #13767
This commit is contained in:
parent
4596847a88
commit
1116cc93ec
crates/ide-completion/src
@ -124,7 +124,12 @@ fn complete_fields(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::tests::check_edit;
|
use ide_db::SnippetCap;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
tests::{check_edit, check_edit_with_config, TEST_CONFIG},
|
||||||
|
CompletionConfig,
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn literal_struct_completion_edit() {
|
fn literal_struct_completion_edit() {
|
||||||
@ -151,6 +156,37 @@ fn baz() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn enum_variant_no_snippets() {
|
||||||
|
let conf = CompletionConfig { snippet_cap: SnippetCap::new(false), ..TEST_CONFIG };
|
||||||
|
check_edit_with_config(
|
||||||
|
conf,
|
||||||
|
"Variant()",
|
||||||
|
r#"
|
||||||
|
enum Enum {
|
||||||
|
Variant(usize),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Enum {
|
||||||
|
fn new(u: usize) -> Self {
|
||||||
|
Self::Va$0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
r#"
|
||||||
|
enum Enum {
|
||||||
|
Variant(usize),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Enum {
|
||||||
|
fn new(u: usize) -> Self {
|
||||||
|
Self::Variant
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn literal_struct_impl_self_completion() {
|
fn literal_struct_impl_self_completion() {
|
||||||
check_edit(
|
check_edit(
|
||||||
|
@ -48,6 +48,9 @@ pub(crate) fn render_tuple_lit(
|
|||||||
fields: &[hir::Field],
|
fields: &[hir::Field],
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> RenderedLiteral {
|
) -> RenderedLiteral {
|
||||||
|
if snippet_cap.is_none() {
|
||||||
|
return RenderedLiteral { literal: format!("{}", path), detail: format!("{}", path) };
|
||||||
|
}
|
||||||
let completions = fields.iter().enumerate().format_with(", ", |(idx, _), f| {
|
let completions = fields.iter().enumerate().format_with(", ", |(idx, _), f| {
|
||||||
if snippet_cap.is_some() {
|
if snippet_cap.is_some() {
|
||||||
f(&format_args!("${{{}:()}}", idx + 1))
|
f(&format_args!("${{{}:()}}", idx + 1))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user