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

Unable to autocomplete Unicode characters with Julia language server #1807

Closed
ChrHorn opened this issue Mar 13, 2022 · 5 comments · Fixed by #4578
Closed

Unable to autocomplete Unicode characters with Julia language server #1807

ChrHorn opened this issue Mar 13, 2022 · 5 comments · Fixed by #4578
Labels
A-language-server Area: Language server client C-bug Category: This is a bug

Comments

@ChrHorn
Copy link
Contributor

ChrHorn commented Mar 13, 2022

The Julia language server is able to autocomplete certain Unicode characters. These always start with a backslash, for example \alpha should complete to α.

Issue seems to be that helix gets the wrong prefix because it doesn't include the backslash (not a word).

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();

The correct results from the server, that start with a backslash, are then filtered out.
items = items
.into_iter()
.filter(|item| {
item.filter_text
.as_ref()
.unwrap_or(&item.label)
.starts_with(&prefix)
})
.collect();

Reproduction steps

File with \alpha, see logs.

Environment

  • Platform: Windows 10, WSL2
  • Terminal emulator: Windows Terminal
  • Helix version: 0.6.0
~/.cache/helix/helix.log
2022-03-13T20:51:22.283 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":6,"line":0},"textDocument":{"uri":"..."}},"id":5}
2022-03-13T20:51:22.285 helix_lsp::transport [INFO] <- {"id":5,"jsonrpc":"2.0","result":{"isIncomplete":true,"items":[{"label":"\\biAlpha","kind":11,"detail":"𝜜","documentation":"𝜜","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝜜"}},{"label":"\\bfalpha","kind":11,"detail":"𝛂","documentation":"𝛂","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝛂"}},{"label":"\\bisansAlpha","kind":11,"detail":"𝞐","documentation":"𝞐","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝞐"}},{"label":"\\alpha","kind":11,"detail":"α","documentation":"α","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"α"}},{"label":"\\bfAlpha","kind":11,"detail":"𝚨","documentation":"𝚨","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝚨"}},{"label":"\\Alpha","kind":11,"detail":"Α","documentation":"Α","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"Α"}},{"label":"\\itAlpha","kind":11,"detail":"𝛢","documentation":"𝛢","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝛢"}},{"label":"\\bisansalpha","kind":11,"detail":"𝞪","documentation":"𝞪","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝞪"}},{"label":"\\bialpha","kind":11,"detail":"𝜶","documentation":"𝜶","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝜶"}},{"label":"\\^alpha","kind":11,"detail":"ᵅ","documentation":"ᵅ","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"ᵅ"}},{"label":"\\bsansAlpha","kind":11,"detail":"𝝖","documentation":"𝝖","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝝖"}},{"label":"\\italpha","kind":11,"detail":"𝛼","documentation":"𝛼","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝛼"}},{"label":"\\bsansalpha","kind":11,"detail":"𝝰","documentation":"𝝰","textEdit":{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":6}},"newText":"𝝰"}}]}}
2022-03-13T20:51:22.286 helix_lsp::transport [INFO] <- {"isIncomplete":true,"items":[{"detail":"𝜜","documentation":"𝜜","kind":11,"label":"\\biAlpha","textEdit":{"newText":"𝜜","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝛂","documentation":"𝛂","kind":11,"label":"\\bfalpha","textEdit":{"newText":"𝛂","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝞐","documentation":"𝞐","kind":11,"label":"\\bisansAlpha","textEdit":{"newText":"𝞐","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"α","documentation":"α","kind":11,"label":"\\alpha","textEdit":{"newText":"α","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝚨","documentation":"𝚨","kind":11,"label":"\\bfAlpha","textEdit":{"newText":"𝚨","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"Α","documentation":"Α","kind":11,"label":"\\Alpha","textEdit":{"newText":"Α","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝛢","documentation":"𝛢","kind":11,"label":"\\itAlpha","textEdit":{"newText":"𝛢","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝞪","documentation":"𝞪","kind":11,"label":"\\bisansalpha","textEdit":{"newText":"𝞪","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝜶","documentation":"𝜶","kind":11,"label":"\\bialpha","textEdit":{"newText":"𝜶","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"ᵅ","documentation":"ᵅ","kind":11,"label":"\\^alpha","textEdit":{"newText":"ᵅ","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝝖","documentation":"𝝖","kind":11,"label":"\\bsansAlpha","textEdit":{"newText":"𝝖","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝛼","documentation":"𝛼","kind":11,"label":"\\italpha","textEdit":{"newText":"𝛼","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}},{"detail":"𝝰","documentation":"𝝰","kind":11,"label":"\\bsansalpha","textEdit":{"newText":"𝝰","range":{"end":{"character":6,"line":0},"start":{"character":0,"line":0}}}}]}
@ChrHorn ChrHorn added the C-bug Category: This is a bug label Mar 13, 2022
@kirawi kirawi added the A-language-server Area: Language server client label Mar 13, 2022
@MichaelByrneAU
Copy link

Just thought I would chime in to say that I have 'solved' this by modifying the char_is_word function to also accept backslashes for my local copy of Helix.

I don't know what broader implications this has on the rest of the application so I haven't opened up a pull request. It does resolve this issue though in allowing for the autocomplete of unicode characters.

@archseer
Copy link
Member

archseer commented Apr 1, 2022

I think the intent there is to keep scanning while char != whitespace, I'd accept a change that does that.

@ChrHorn
Copy link
Contributor Author

ChrHorn commented Apr 1, 2022

Just thought I would chime in to say that I have 'solved' this by modifying the char_is_word function to also accept backslashes for my local copy of Helix.

I did something similar. The problem with this solution is, that you can't chain multiple completions. For example \alpha<Tab>\beta<Tab> does not work.

To solve this you need an exemption for \.
When the nonword char is a \: treat it as a boundary, but include the \.
For every other nonword char: don't include it.

@leoflotor
Copy link

leoflotor commented Apr 13, 2022

Just thought I would chime in to say that I have 'solved' this by modifying the char_is_word function to also accept backslashes for my local copy of Helix.

I did something similar. The problem with this solution is, that you can't chain multiple completions. For example \alpha<Tab>\beta<Tab> does not work.

To solve this you need an exemption for \. When the nonword char is a \: treat it as a boundary, but include the \. For every other nonword char: don't include it.

Hi! Sorry to ask, I am not really fluent using rust. Could you explain me how can I include this exemption and how to treat \ as a boundary and include it?

@ChrHorn
Copy link
Contributor Author

ChrHorn commented May 2, 2022

Sorry, I somehow missed this.

I did not implement this so far, just described how it should work. Not really fluent in Rust either. So far I just replaced line 3493 with this hacky workaround:

    let offset = iter.take_while(|ch| chars::char_is_word(*ch) || *ch == '\\').count();

VarLad added a commit to VarLad/helix that referenced this issue May 19, 2022
ChrHorn added a commit to ChrHorn/helix that referenced this issue Nov 3, 2022
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
ChrHorn added a commit to ChrHorn/helix that referenced this issue Nov 3, 2022
PR helix-editor#4134 switched the autocomplete menu from alphabetical to fuzzy
sorting. 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
@the-mikedavis the-mikedavis linked a pull request Nov 4, 2022 that will close this issue
archseer added a commit that referenced this issue Nov 17, 2022
PR #4134 switched the autocomplete menu from alphabetical to fuzzy
sorting. This commit removes the still existing filtering by prefix and
should enable full fuzzy sorting of the autocomplete menu.

closes #3084, #1807

Co-authored-by: Blaž Hrastnik <[email protected]>
herkhinah pushed a commit to herkhinah/helix that referenced this issue Dec 11, 2022
PR helix-editor#4134 switched the autocomplete menu from alphabetical to fuzzy
sorting. 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

Co-authored-by: Blaž Hrastnik <[email protected]>
freqmod pushed a commit to freqmod/helix that referenced this issue Feb 8, 2023
PR helix-editor#4134 switched the autocomplete menu from alphabetical to fuzzy
sorting. 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

Co-authored-by: Blaž Hrastnik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug
Projects
None yet
5 participants