mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 01:38:13 +00:00
return immediately from render_tuple_lit
if snippet_cap
is None
partially addresses #13767
This commit is contained in:
parent
4596847a88
commit
1116cc93ec
2 changed files with 40 additions and 1 deletions
|
@ -124,7 +124,12 @@ fn complete_fields(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tests::check_edit;
|
||||
use ide_db::SnippetCap;
|
||||
|
||||
use crate::{
|
||||
tests::{check_edit, check_edit_with_config, TEST_CONFIG},
|
||||
CompletionConfig,
|
||||
};
|
||||
|
||||
#[test]
|
||||
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]
|
||||
fn literal_struct_impl_self_completion() {
|
||||
check_edit(
|
||||
|
|
|
@ -48,6 +48,9 @@ pub(crate) fn render_tuple_lit(
|
|||
fields: &[hir::Field],
|
||||
path: &str,
|
||||
) -> RenderedLiteral {
|
||||
if snippet_cap.is_none() {
|
||||
return RenderedLiteral { literal: format!("{}", path), detail: format!("{}", path) };
|
||||
}
|
||||
let completions = fields.iter().enumerate().format_with(", ", |(idx, _), f| {
|
||||
if snippet_cap.is_some() {
|
||||
f(&format_args!("${{{}:()}}", idx + 1))
|
||||
|
|
Loading…
Reference in a new issue