microsoft / cascadia-code

This is a fun, new monospaced font that includes programming ligatures and is designed to enhance the modern look and feel of the Windows Terminal.
Other
25.74k stars 804 forks source link

Left arrow ligature in JavaScript + Flow #113

Open SergioMorchon opened 5 years ago

SergioMorchon commented 5 years ago

Environment

Cascadia Code version number: 1909.16
Application (with version) used to display text: Visual Studio Code 1.38.1
OS platform and version: Windows 10 Pro, 18362
Screen resolution (i.e. 220dpi): 1920x1080 @ 100%

Any other software? No

Steps to reproduce

  1. Open a JavaSript file that will be used with Flow (https://flow.org/).
  2. Open the following flow file: react-redux.
  3. You'll see declare type MapStateToProps<-S, -OP, +SP> =

Expected behavior

Don't apply a ligature in that case. It should keep as <-, because < is used to declare a generic, and - for write-only (see https://flow.org/en/docs/types/interfaces/#interface-property-variance-read-only-and-write-only-).

Actual behavior

That <-S is changed by a left arrow.

ExE-Boss commented 5 years ago

Same with TypeScript (and other programming languages with generics):

let foo: Bar<-3>;
aaronbell commented 5 years ago

It sounds like this is not something that can be special cased out in the font code (as in, ignore ligature when X occurs). That said, I can provide a stylistic set that turns off that specific ligature generally that would need to be accessible via font settings.

ExE-Boss commented 5 years ago

Another option would be to improve the TextMate language grammar so that, - followed by a number has a different TextMate scope from the enclosing generics. Same with Flow’s read‑only and write‑only modifiers (+ and -).

This will fix it in VS Code, but not on GitHub: Cascadia Code – TypeScript – Broken generics with negative number

bterlson commented 5 years ago

FWIW, I think flow is uniquely impacted by this given its variance sigils for generic parameters. TypeScript is impacted, but I suspect only in very niche cases where users are passing a negative number literal type. I think C# generic syntax doesn't allow <-.