Skip to content

Commit d0930c4

Browse files
committed
Disable Fira Code ligatures in the Monaco editors
Fira Code's programming ligatures rewrote valid GraphQL into misleading glyphs — `Int!=1` (a non-null `Int` defaulting to `1`) rendered as `Int≠1`. Pass an explicit `font-feature-settings` string that turns ligatures off but stays unequal to Monaco's OFF constant, so the per-character caret measurement from the #4040 Windows fix is preserved.
1 parent 3d13e7d commit d0930c4

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphiql/react': patch
3+
---
4+
5+
Disable Fira Code's font ligatures in the Monaco editors. Programming ligatures rewrote valid GraphQL into misleading glyphs — most notably `Int!=1` (a non-null `Int` with a default value of `1`) rendered as `Int≠1`, implying an inequality that isn't there. Characters now render literally. The Windows caret fix from #4040 is preserved.

packages/graphiql-react/src/utility/create-editor.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@ export function createEditor(
5959
},
6060
scrollBeyondLastLine: false, // cleans up unnecessary "padding-bottom" on each editor
6161
fontFamily: '"Fira Code"',
62-
// Enable font ligatures and fix incorrect caret position on Windows
63-
// See: https://github.com/graphql/graphiql/issues/4040
64-
fontLigatures: true,
62+
// Disable Fira Code's ligatures without regressing the Windows caret fix.
63+
// This is deliberately an explicit `font-feature-settings` string, not
64+
// `false`: Monaco only takes its monospace caret-measurement fast path when
65+
// this exactly equals its OFF constant (`"liga" off, "calt" off`), and that
66+
// fast path mis-positions the caret with Fira Code on Windows (#4040). Any
67+
// other string keeps ligatures off while forcing per-character width
68+
// measurement, so the caret stays correct. See PR #4390 for the full write-up.
69+
fontLigatures: '"liga" off, "calt" off, "clig" off',
6570
lineNumbersMinChars: 2, // reduce line numbers width on the left size
6671
roundedSelection: false, // prevent multiline text selection from highlighting +1 characters after beginning/end of selection
6772
tabIndex: -1, // Do not allow tabbing into the editor, only via by pressing Enter or its container

0 commit comments

Comments
 (0)