Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes backslash unicode autocompletion #2504

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update commands.rs
  • Loading branch information
VarLad authored May 23, 2022
commit 16e3d9bc203b21291d84d8441af7c113bdb33dea
17 changes: 16 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
@@ -3571,6 +3571,16 @@ pub fn completion(cx: &mut Context) {
None => return,
};

let capabilities = language_server.capabilities();
let mut trigger_list = Vec::new();
if let Some(lsp::CompletionOptions {
trigger_characters: Some(triggers),
..
}) = &capabilities.completion_provider
{
trigger_list = triggers.clone();
}

let offset_encoding = language_server.offset_encoding();
let text = doc.text().slice(..);
let cursor = doc.selection(view.id).primary().cursor(text);
@@ -3587,7 +3597,12 @@ pub fn completion(cx: &mut Context) {
use helix_core::chars;
let mut iter = text.chars_at(cursor);
iter.reverse();
let offset = iter.take_while(|ch| chars::char_is_word(*ch) || *ch == '\\').count();
let offset;
if trigger_list.len() == 0 {
offset = iter.take_while(|ch| chars::char_is_word(*ch)).count();
} else {
offset = iter.take_while(|ch| trigger_list.iter().any(|trigger| trigger.contains(*ch))).count();
}
let start_offset = cursor.saturating_sub(offset);
let prefix = text.slice(start_offset..cursor).to_string();