Skip to content

Eliminate ad hoc creation of function completion items #849

@jennybc

Description

@jennybc

Loose end discovered while working on #819:

if rhs.node_type() == NodeType::FunctionDefinition {
if let Some(parameters) = rhs.child_by_field_name("parameters") {
let parameters = context
.document
.contents
.node_slice(&parameters)?
.to_string();
item.detail = Some(join!(label, parameters));
}
item.kind = Some(CompletionItemKind::FUNCTION);
item.insert_text_format = Some(InsertTextFormat::SNIPPET);
item.insert_text = Some(format!("{}($0)", label));
}

completion_item_from_assignment(), which is used for document completions, hand crafts a function completion item, which means it doesn't benefit from all the smarts in completion_item_from_function().

I actually found this problem when writing tests for #819, because my first crack at it was with a user-defined function in the global environment. I wondered why things weren't working! This issue is a reminder to me to come back and route this through completion_item_from_function() and to look hard for any other instances of similar.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions