Skip to content

Language Service: Resolve partials against the view root the index found - #2184

Merged
marcoroth merged 1 commit into
mainfrom
language-service-view-root
Aug 11, 2026
Merged

Language Service: Resolve partials against the view root the index found#2184
marcoroth merged 1 commit into
mainfrom
language-service-view-root

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 11, 2026

Copy link
Copy Markdown
Owner

This pull request fixes go to definition for projects that do not keep their templates in app/views.

DefinitionProvider located a project's view root by looking for a literal string in the document path:

const VIEWS_DIRECTORY = "/app/views/"

A project laid out any other way never matched, so it got no view root at all, and go to definition could only find partials that happen to sit in the same directory as the file being edited:

app/templates/events/show.html.erb

<%= render "shared/header" %>

Nothing resolves, even though app/templates/shared/_header.html.erb is right there.

buildPartialIndex does not assume the conventional layout. It looks for app/views, falls back to the project root when there is nothing there, and records the answer as viewRoot. So what was needed to resolve that render call was already sitting in the project's index, unused by this provider.

Follow up on #2168.

@github-actions github-actions Bot added language-server @herb-tools/language-server and Language Server Protocol support typescript TypeScript source across the javascript/ packages language-service @herb-tools/language-service HTML+ERB language service labels Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 6add25c


✅ Preview deployment has been cleaned up.

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@2184
npx https://pkg.pr.new/@herb-tools/language-server@2184
npx https://pkg.pr.new/@herb-tools/linter@2184

commit: 6add25c

@marcoroth
marcoroth marked this pull request as ready for review August 11, 2026 17:44
@marcoroth
marcoroth merged commit 26b6f72 into main Aug 11, 2026
23 checks passed
@marcoroth
marcoroth deleted the language-service-view-root branch August 11, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

language-server @herb-tools/language-server and Language Server Protocol support language-service @herb-tools/language-service HTML+ERB language service typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant