@@ -4142,6 +4142,7 @@ pub fn completion(cx: &mut Context) {
4142 iter.reverse();
4142 iter.reverse();
4143 let offset = iter.take_while(|ch| chars::char_is_word(*ch)).count();
4143 let offset = iter.take_while(|ch| chars::char_is_word(*ch)).count();
4144 let start_offset = cursor.saturating_sub(offset);
4144 let start_offset = cursor.saturating_sub(offset);
4145+ let prefix = text.slice(start_offset..cursor).to_string();
4146 cx.callback(
4147 cx.callback(
@@ -4154,7 +4155,7 @@ pub fn completion(cx: &mut Context) {
4157− let items = match response {
4158+ let mut items = match response {
4158 Some(lsp::CompletionResponse::Array(items)) => items,
4159 Some(lsp::CompletionResponse::Array(items)) => items,
4159 // TODO: do something with is_incomplete
4160 // TODO: do something with is_incomplete
4160 Some(lsp::CompletionResponse::List(lsp::CompletionList {
4161 Some(lsp::CompletionResponse::List(lsp::CompletionList {
@@ -4164,6 +4165,18 @@ pub fn completion(cx: &mut Context) {
4164 None => Vec::new(),
4165 None => Vec::new(),
4168+ if !prefix.is_empty() {
4174+ .unwrap_or(&item.label)
4175+ .starts_with(&prefix)
4167 if items.is_empty() {
4180 if items.is_empty() {
4168 // editor.set_error("No completion available".to_string());
4181 // editor.set_error("No completion available".to_string());