Skip to content

Send ERB virtual state when a document is opened - #4267

Open
rafayqayyum wants to merge 1 commit into
Shopify:mainfrom
rafayqayyum:erb-virtual-state-on-open
Open

rafayqayyum wants to merge 1 commit into
Shopify:mainfrom
rafayqayyum:erb-virtual-state-on-open

Conversation

@rafayqayyum

Copy link
Copy Markdown

Motivation

Closes #2784

Hovering an HTML element in a freshly opened ERB file fails with Unable to resolve text model content for resource embedded-content://… until the file is edited. That explains why it reproduced for some people and not others.

Implementation

Document#initialize calls parse!, so after didOpen the document no longer needs parsing. The delegate/textDocument/virtualState notification in BaseServer is only sent when document.parse! returns true, which first happens after an edit, so the extension's embedded-content provider has nothing for a newly opened file.

text_document_did_open now sends the virtual state for ERB documents when the client supports request delegation. I kept this in server.rb rather than base_server.rb to avoid conflicting with #4261, which reworks the parse/notify block there (it keeps the parse!-true condition, so it doesn't cover this case).

Automated Tests

Added a server test that opens an ERB document with request delegation enabled and asserts the virtualState notification is sent with the host-language source. It fails on main (no notification is sent).

Manual Tests

  1. Open this repository in VS Code so the extension uses the local server.
  2. Open any .html.erb file and, without editing it, hover an HTML tag.
  3. On main: the "Unable to resolve text model content" error appears. With this branch: the HTML hover shows.

@rafayqayyum
rafayqayyum requested a review from a team as a code owner November 8, 2026 16:25
Copilot AI balanced review requested due to automatic review settings November 8, 2026 16:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

Error: Unable to resolve text model content for resource embedded when hovering HTML

2 participants