Disable Fira Code ligatures in the Monaco editors#4430
Draft
trevor-scheer wants to merge 2 commits into
Draft
Conversation
🦋 Changeset detectedLatest commit: 131a29e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
trevor-scheer
force-pushed
the
trevor/disable-editor-ligatures
branch
from
July 15, 2026 02:30
d0930c4 to
131a29e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Monaco editors use Fira Code, whose programming ligatures rewrite certain character sequences into single glyphs. For prose that's nice; for GraphQL source it actively misrepresents the syntax.
The motivating case:
Int!=1means "a non-nullInt(Int!) with a default value of1(=1)". Fira Code renders the adjacent!and=as a≠ligature, so it reads asInt ≠ 1— an inequality that has no meaning in GraphQL and directly contradicts what the code does. Other sequences (=>,==,->,<=, …) are similarly re-glyphed.This PR disables ligatures so characters render literally — without regressing the Windows caret fix that is the reason ligatures were on in the first place.
Background: why ligatures were enabled
Ligatures weren't a deliberate typographic choice. They were switched on as a side effect of fixing a caret bug:
Ctrl+Aselections were visually misaligned.fontLigatures: true. The commit history on that PR (try/try/see if we need font-feature-settings/back to fira code) shows it was found empirically; the mechanism was never the point, and the resulting ligatures were collateral.Why
fontLigatures: falsewould reintroduce the bugThe caret fix and the ligatures are the same knob, because of how Monaco decides whether it can use its "monospace" fast path for caret math.
In
fontMeasurements.js:and
EditorFontLigatures.OFFis the exact string:Monaco resolves the
fontLigaturesoption to afont-feature-settingsstring:fontLigaturesvaluefont-feature-settingsisMonospacefalse"liga" off, "calt" off(=OFF)truetrue"liga" on, "calt" onfalsefalse(unless it equalsOFF)When
isMonospaceistrue, Monaco assumes every glyph is exactlytypicalHalfwidthCharacterWidthand positions the caret arithmetically instead of measuring. With Fira Code on Windows, the real advance widths don't match that assumption, so the caret drifts — that's #4040.So
fontLigatures: falseresolves to the exactOFFstring, flipsisMonospaceback totrue, and silently regresses the Windows caret. The two behaviors are coupled through this single string-equality check.The fix
Pass an explicit
font-feature-settingsstring that (a) turns ligatures off and (b) is not byte-for-byte equal to Monaco'sOFFconstant:liga,calt, andcligcover the OpenType features Fira Code uses to deliver its programming ligatures, so ligatures are fully disabled.'"liga" off, "calt" off',isMonospacestaysfalseand Monaco keeps measuring per-character widths — i.e. the exact code path the [graphiql] The text cursor doesn't work well in the Playground page. It doesn't point correctly to end of the line or end of the text. #4040 fix relied on. Windows caret behavior is unchanged.The inline comment in
create-editor.tsexplains this coupling and points back here so the next person doesn't "simplify" it tofalseand quietly break Windows.Validation Steps
yarn dev(or run any GraphiQL example) and paste:Int!=1renders as literal characters, notInt≠1. Spot-check=>,==,->render literally too.End, and confirm the caret lands at the true end of the line;Ctrl+Ashould highlight the full text with no horizontal offset.