mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:15:58 +02:00
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:
@ -60,8 +60,12 @@ impl LanguageServer {
|
||||
.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 {
|
||||
label: r.suggestion.value.clone(),
|
||||
label: label_value.clone(),
|
||||
label_details: r
|
||||
.kind
|
||||
.clone()
|
||||
@ -98,7 +102,7 @@ impl LanguageServer {
|
||||
start,
|
||||
end: params.text_document_position.position,
|
||||
},
|
||||
new_text: r.suggestion.value,
|
||||
new_text: label_value,
|
||||
})),
|
||||
..Default::default()
|
||||
}
|
||||
@ -119,9 +123,9 @@ impl LanguageServer {
|
||||
SuggestionKind::Command(c) => match c {
|
||||
CommandType::Keyword => Some(CompletionItemKind::KEYWORD),
|
||||
CommandType::Builtin => Some(CompletionItemKind::FUNCTION),
|
||||
CommandType::Custom => Some(CompletionItemKind::METHOD),
|
||||
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::File => Some(CompletionItemKind::FILE),
|
||||
|
Reference in New Issue
Block a user