Skip to content

fix(site): make playground autocomplete context-aware - #3544

Merged
diegomura merged 1 commit into
masterfrom
diegomura/context-aware-style-autocomplete
Aug 27, 2026
Merged

fix(site): make playground autocomplete context-aware#3544
diegomura merged 1 commit into
masterfrom
diegomura/context-aware-style-autocomplete

Conversation

@diegomura

Copy link
Copy Markdown
Owner

Playground completions used a 30/200-char regex peek to guess context, so it only recognized a style object when the word "style" happened to sit within 200 chars — past the first couple of properties in a StyleSheet.create block it fell through and suggested react-pdf components instead of style keys.

Context now comes from the JS/JSX syntax tree: components for tag names (<V, </Vi), props for attribute names (<View w), and style keys only inside a style={{ … }} object or one nested a level under StyleSheet.create({ … }). Everywhere else — stylesheet top-level names, style values, JSX text, plain code, unrelated object literals — it now offers nothing rather than a wrong list.

Verified with assertions against a real EditorState + javascript({ jsx: true }) for each of those contexts, including the multi-line stylesheet that broke the old heuristic.

🤖 Generated with Claude Code

Derive the completion context from the JS/JSX syntax tree instead of a
30/200-char regex peek, which only saw "style" within 200 chars and so
dumped component names into stylesheet blocks.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2d53414

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-pdf Building Building Preview Aug 27, 2026 11:05pm

@diegomura
diegomura merged commit 90882ab into master Aug 27, 2026
16 of 17 checks passed
@diegomura
diegomura deleted the diegomura/context-aware-style-autocomplete branch August 27, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant