pub fn build_version_completion(
display_item: &VersionDisplayItem,
insert_range: Option<Range>,
) -> CompletionItemExpand description
Builds a completion item for a version string.
Creates a properly formatted LSP CompletionItem with version metadata in a simplified format matching Code Actions (Cmd+.) style.
§Arguments
display_item- Version display metadata with label, description, and flagsinsert_range- Optional LSP range where the completion should replace text. IfNone, the completion will insert at cursor position without replacing.
§Returns
A complete CompletionItem with simple index-based sorting and preselect.
§Format
- Label:
"version"or"version (latest)"for the latest version - Detail:
"Update package_name to version" - Preselect:
truefor latest version,falseotherwise - Sort: Index-based (00000, 00001, etc.)
§Examples
use deps_core::completion::{build_version_completion, VersionDisplayItem};
use tower_lsp_server::ls_types::Range;
// Without range - insert at cursor
let display_item = VersionDisplayItem::new(version, "serde", 0, true);
let item = build_version_completion(&display_item, None);
assert_eq!(item.label, display_item.label);
// With range - replace existing text
let range = Range::default();
let item = build_version_completion(&display_item, Some(range));