microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.75k stars 28.17k forks source link

Font ligatures not working properly with C and C++ syntax highlighting #17306

Closed vittorioromeo closed 7 years ago

vittorioromeo commented 7 years ago

Steps to Reproduce:

  1. Set font to "Fira Code" (or any similar font which uses programming ligatures).
  2. Enable ligatures with "editor.fontLigatures": true.
  3. Write code for a lambda with trailing return type or a -> access to a method.
  4. The ligatures are not expanded correctly (see screenshot below).

incorrect ligatures with C++ syntax highlighting


Setting the syntax to "Plain Text" makes the ligatures work correctly.

correct ligatures with Plain Text syntax highlighting


(This also applies to other ligatures, not only ->.)

(This also applies to C syntax highlighting.)

siegebell commented 7 years ago

This is a partial duplicate of #2870 - the C++ grammar is parsing - and > into separate tokens. If you are using a built-in grammar for C++, you should make a feature request to have -> and other operators parsed as one token.

Or you can use prettify-symbols-mode - see this thread for a discussion on how to make it work for Fira Code.

siegebell commented 7 years ago

Actually, I think this is a bug in the built-in C++ grammar. Commit 5598ee0 ensures that identical tokens are merged, but while - is given scope keyword.operator.c, the grammar incorrectly assigns > scope keyword.operator.comparison.c.

siegebell commented 7 years ago

related: atom/language-c#177

aeschli commented 7 years ago

Thanks @siegebell for the analysis. Closing as dup of atom/language-c#177