Make multiple import edits work for completions

This commit is contained in:
Lukas Wirth 2021-10-04 21:44:33 +02:00
parent 046c85ef0c
commit 454ecd167c
17 changed files with 141 additions and 87 deletions

View file

@ -41,7 +41,7 @@ impl Snippet {
snippet: &[String],
description: &[String],
requires: &[String],
scope: Option<SnippetScope>,
scope: SnippetScope,
) -> Option<Self> {
// validate that these are indeed simple paths
if requires.iter().any(|path| match ast::Path::parse(path) {
@ -57,7 +57,7 @@ impl Snippet {
let description = description.iter().join("\n");
let description = if description.is_empty() { None } else { Some(description) };
Some(Snippet {
scope: scope.unwrap_or(SnippetScope::Expr),
scope,
label,
snippet,
description,
@ -89,7 +89,7 @@ impl PostfixSnippet {
snippet: &[String],
description: &[String],
requires: &[String],
scope: Option<PostfixSnippetScope>,
scope: PostfixSnippetScope,
) -> Option<Self> {
// validate that these are indeed simple paths
if requires.iter().any(|path| match ast::Path::parse(path) {
@ -105,7 +105,7 @@ impl PostfixSnippet {
let description = description.iter().join("\n");
let description = if description.is_empty() { None } else { Some(description) };
Some(PostfixSnippet {
scope: scope.unwrap_or(PostfixSnippetScope::Expr),
scope,
label,
snippet,
description,