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 3 commits
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
17 changes: 16 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
VarLad marked this conversation as resolved.
Show resolved Hide resolved

let offset_encoding = language_server.offset_encoding();
let text = doc.text().slice(..);
let cursor = doc.selection(view.id).primary().cursor(text);
Expand All @@ -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)).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();
}
VarLad marked this conversation as resolved.
Show resolved Hide resolved
let start_offset = cursor.saturating_sub(offset);
let prefix = text.slice(start_offset..cursor).to_string();

Expand Down