VSCode handling of unicode automatic completion

Hey,

I find that the behavior in VSCode for the handling of unicode completion surprising. In the folloiwng examples, I will denote the position of the cursor when i hit the tab key (for autocompletion) <TAB> :

  • myfunction(\alpha<TAB> works as expected.
  • myfunction(\alpha<TAB>) also works.
  • myfunction(\alpha<TAB>hat) does not.
  • myfunction(\alpha<TAB> hat) does work (notice the space after the cursor).

Although, in the REPL, the three work as expected and write a α. This is frustrating as it happens a lot with my naming conventions. Is this expected, or am I missing some configuration options ?

It seems like if there is a letter after the cursor, it does not work, while if there is something else (a space, a closing parenthesis, a + sign…) it does, although the REPL works whatever you have after the cursor (which is in my oppinon a better choice).

3 Likes

You should use

myfunction(\alpha<TAB>\hat<TAB>

Better still is to get a utility such as Ukelele (mac) that allows you to assign Unicode characters to keystrokes and chords. For your example, I’m able to do <ALT>-a<ALT>-,

1 Like

No you missed my point, I do not want α̂, but rather αhat, indeed the text hat is no well-chosen for the example.

Say i have two variables αtheoretical and αobserved

If you are just referring to typing part of the name with a leading ⍺ and getting tab completion, then I can’t reproduce your problem at the REPL inside or outside of VS Code.

On a related note, I wish the VSCode extension had some sort of “Greek mode” where we could switch to the Greek alphabet in the keyboard temporarily. That is, typing a, b, d, … would be automatically converted into the unicode alpha, beta, delta, …

I am referring to exactly what I described :

  • type somecharacters
  • move your cursor in the middle of it at some<CURSOR>character
  • type \alpha
  • hit Tab.

Works in the REPL, not in a .jl file in vscode. Do you confirm that it works on your system ?

It works the same in jl files as in the REPL for me.

Yeah I can see it does not work in vs code, the end result of that for me is: some\alpha characters

1 Like

I have this problem too, and it’s infuriating (although not infuriating enough for me to have done anything about it). Thanks for bringing it up!

3 Likes

Okay at least i am not the only one having this issue. Maybe we could turn this into an issue on the vs-code julia repo ?

1 Like

I do not seem to experience this problem, but have a Fast Unicode Math Characters VSCode extension installed.

This is what I get and it seems OK, assuming I understood what you wanted:

myfunction(\alpha → myfunction(α)

myfunction(\alpha) → myfunction(α)

myfunction(\alphahat) → myfunction(αhat)

myfunction(\alpha hat) → myfunction(α hat)

VS Code v1.74.2
Julia add-in v1.38.2
Windows 10

Yes i think you understood what i wanted, and this is exactly the behavior i am NOT getting. For me, when hitting TAB with the cursor right after \alpha in this example, nothing happens.

So it looks like YMMV…

I also can’t repro this:
Peek 2023-01-09 10-53

It’s possible you have changed a setting that breaks this – does anything stand out under Editor > Suggestions?

@pfitzseb I have the same behavior as you, but you are not trying the interesting case:

  • Type \alphahat
  • Go back you cursor 3 times so that you have it between \alpha and hat
  • hit Tab.

This is not what you are showing. I’m trying to screen-capture but i have to find the right tool to do it :slight_smile:

Ah, yeah, that’s a known issue (I think someone opened it already).

1 Like

Ok it is known already, fine. Thanks for taking the time, hope it’ll be fixed someday.

Did you try the Fast Unicode Math Characters VSCode extension? I do not have any problem with your example.

Yep, does not help, sadly. But it also looks like the proposed shortcuts from this extensions are not showing up at all in the autocompletion menu : for example, while \forall is there (added by the Julia extension), \all is not (while the README of Fast Unicode Math Characters mentions it explicitly as a shortcut for the same Unicode character). Therefore, I might have an issue with the installation of said extension, I might have to take another look.