Skip to content

Commit f71ab82

Browse files
committed
Remove word extraction from textEdit.
When textEdit.range.start.character is larger than complete_position, it is problematic trying to extract. Close #795.
1 parent ec4af74 commit f71ab82

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

src/types.rs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -527,33 +527,15 @@ pub struct VimCompleteItemUserData {
527527

528528
impl VimCompleteItem {
529529
pub fn from_lsp(lspitem: &CompletionItem, complete_position: Option<u64>) -> Fallible<Self> {
530+
info!(
531+
"LSP CompletionItem to VimCompleteItem: {:?}, {:?}",
532+
lspitem, complete_position
533+
);
530534
let abbr = lspitem.label.clone();
531-
let mut word = lspitem.insert_text.clone().unwrap_or_default();
532-
if word.is_empty() {
533-
match (lspitem.text_edit.clone(), complete_position) {
534-
(Some(ref text_edit), Some(complete_position))
535-
if !text_edit.new_text.is_empty() =>
536-
{
537-
// TextEdit range start might be different from vim expected completion start.
538-
// From spec, TextEdit can only span one line, i.e., the current line.
539-
if text_edit.range.start.character != complete_position {
540-
word = text_edit
541-
.new_text
542-
.get((complete_position as usize)..)
543-
.and_then(|line| line.split_whitespace().next())
544-
.map_or_else(String::new, ToOwned::to_owned);
545-
} else {
546-
word = text_edit.new_text.clone();
547-
}
548-
}
549-
(Some(ref text_edit), _) if !text_edit.new_text.is_empty() => {
550-
word = text_edit.new_text.clone();
551-
}
552-
(_, _) => {
553-
word = lspitem.label.clone();
554-
}
555-
}
556-
}
535+
let word = lspitem
536+
.insert_text
537+
.clone()
538+
.unwrap_or_else(|| lspitem.label.clone());
557539

558540
let snippet;
559541
if lspitem.insert_text_format == Some(InsertTextFormat::Snippet) {

0 commit comments

Comments
 (0)