feat(lsp): completion items now respect the append_whitespace flag (#15247)

# Description

Append space if marked as required.
Aligned behavior as the REPL completion.

# User-Facing Changes

# Tests + Formatting

Adjusted

# After Submitting
This commit is contained in:
zc he 2025-03-05 19:45:27 +08:00 committed by GitHub
parent 4779d69de6
commit 49f92e9090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,8 +60,12 @@ impl LanguageServer {
.then_some(engine_state.find_decl(r.suggestion.value.as_bytes(), &[])?) .then_some(engine_state.find_decl(r.suggestion.value.as_bytes(), &[])?)
}); });
let mut label_value = r.suggestion.value;
if r.suggestion.append_whitespace {
label_value.push(' ');
}
CompletionItem { CompletionItem {
label: r.suggestion.value.clone(), label: label_value.clone(),
label_details: r label_details: r
.kind .kind
.clone() .clone()
@ -98,7 +102,7 @@ impl LanguageServer {
start, start,
end: params.text_document_position.position, end: params.text_document_position.position,
}, },
new_text: r.suggestion.value, new_text: label_value,
})), })),
..Default::default() ..Default::default()
} }
@ -119,9 +123,9 @@ impl LanguageServer {
SuggestionKind::Command(c) => match c { SuggestionKind::Command(c) => match c {
CommandType::Keyword => Some(CompletionItemKind::KEYWORD), CommandType::Keyword => Some(CompletionItemKind::KEYWORD),
CommandType::Builtin => Some(CompletionItemKind::FUNCTION), CommandType::Builtin => Some(CompletionItemKind::FUNCTION),
CommandType::Custom => Some(CompletionItemKind::METHOD),
CommandType::Alias => Some(CompletionItemKind::REFERENCE), CommandType::Alias => Some(CompletionItemKind::REFERENCE),
CommandType::External | CommandType::Plugin => Some(CompletionItemKind::INTERFACE), CommandType::External => Some(CompletionItemKind::INTERFACE),
CommandType::Custom | CommandType::Plugin => Some(CompletionItemKind::METHOD),
}, },
SuggestionKind::Directory => Some(CompletionItemKind::FOLDER), SuggestionKind::Directory => Some(CompletionItemKind::FOLDER),
SuggestionKind::File => Some(CompletionItemKind::FILE), SuggestionKind::File => Some(CompletionItemKind::FILE),