Skip to content

Commit

Permalink
Remove prefix filtering from autocomplete menu
Browse files Browse the repository at this point in the history
This commit removes the still existing filtering by prefix and should
enable full fuzzy sorting of the autocomplete menu.

closes helix-editor#3084, helix-editor#1807
  • Loading branch information
ChrHorn committed Nov 3, 2022
1 parent ba394dc commit a5e1b01
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3912,7 +3912,6 @@ pub fn completion(cx: &mut Context) {
iter.reverse();
let offset = iter.take_while(|ch| chars::char_is_word(*ch)).count();
let start_offset = cursor.saturating_sub(offset);
let prefix = text.slice(start_offset..cursor).to_string();

cx.callback(
future,
Expand All @@ -3922,7 +3921,7 @@ pub fn completion(cx: &mut Context) {
return;
}

let mut items = match response {
let items = match response {
Some(lsp::CompletionResponse::Array(items)) => items,
// TODO: do something with is_incomplete
Some(lsp::CompletionResponse::List(lsp::CompletionList {
Expand All @@ -3932,18 +3931,6 @@ pub fn completion(cx: &mut Context) {
None => Vec::new(),
};

if !prefix.is_empty() {
items = items
.into_iter()
.filter(|item| {
item.filter_text
.as_ref()
.unwrap_or(&item.label)
.starts_with(&prefix)
})
.collect();
}

if items.is_empty() {
// editor.set_error("No completion available");
return;
Expand Down

0 comments on commit a5e1b01

Please sign in to comment.