Remove word extraction from `textEdit`.
When textEdit.range.start.character is larger than complete_position,
it is problematic trying to extract.
Close
@@ -527,33 +527,15 @@ pub struct VimCompleteItemUserData {
impl VimCompleteItem {
pub fn from_lsp(lspitem: &CompletionItem, complete_position: Option<u64>) -> Fallible<Self> {
+ info!(
+ "LSP CompletionItem to VimCompleteItem: {:?}, {:?}",
+ lspitem, complete_position
+ );
let abbr = lspitem.label.clone();
- let mut word = lspitem.insert_text.clone().unwrap_or_default();
- if word.is_empty() {
- match (lspitem.text_edit.clone(), complete_position) {
- (Some(ref text_edit), Some(complete_position))
- if !text_edit.new_text.is_empty() =>
- {
- // TextEdit range start might be different from vim expected completion start.
- // From spec, TextEdit can only span one line, i.e., the current line.
- if text_edit.range.start.character != complete_position {
- word = text_edit
- .new_text
- .get((complete_position as usize)..)
- .and_then(|line| line.split_whitespace().next())
- .map_or_else(String::new, ToOwned::to_owned);
- } else {
- word = text_edit.new_text.clone();
- }
- }
- (Some(ref text_edit), _) if !text_edit.new_text.is_empty() => {
- word = text_edit.new_text.clone();
- }
- (_, _) => {
- word = lspitem.label.clone();
- }
- }
- }
+ let word = lspitem
+ .insert_text
+ .clone()
+ .unwrap_or_else(|| lspitem.label.clone());
let snippet;
if lspitem.insert_text_format == Some(InsertTextFormat::Snippet) {
