Skip to content

[ty] Apply workspace settings to virtual files#23228

Merged
BurntSushi merged 3 commits intoastral-sh:mainfrom
Hugo-Polloli:virtual-files-settings
Feb 11, 2026
Merged

[ty] Apply workspace settings to virtual files#23228
BurntSushi merged 3 commits intoastral-sh:mainfrom
Hugo-Polloli:virtual-files-settings

Conversation

@Hugo-Polloli
Copy link
Contributor

Summary

Fixes astral-sh/ty#2783

  • Commit [ty] centralize virtual project fallback:
    • Refactors Session to centralize the "first project" virtual fallback heuristic used by project selection.
  • Commit [ty] apply workspace settings to virtual files:
    • Fixes DocumentSnapshot workspace settings resolution for virtual documents (for example untitled://...).
    • Ensures virtual documents use the same project owner heuristic as project_state, then resolve workspace settings from that owner.
    • Adds an e2e regression test for virtual files with variable-type inlay hints disabled.

Test Plan

  • cargo test -p ty_server --test e2e inlay_hints

@ntBre ntBre added the ty Multi-file analysis & type inference label Feb 11, 2026
@Hugo-Polloli Hugo-Polloli marked this pull request as ready for review February 11, 2026 15:42
@Hugo-Polloli Hugo-Polloli force-pushed the virtual-files-settings branch from daba328 to 342f461 Compare February 11, 2026 15:54
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

This LGTM with a nit on the naming. Nice fix!

// need to figure out which project should this virtual path
// belong to: https://github.com/astral-sh/ty/issues/794 (e.g.
// look for the first project with an overlapping search path?)
fn first_project_state(&self) -> &ProjectState {
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd prefer that this be called something like project_state_virtual_fallback or something similar. And then apply that name to first_project_state_mut and also first_settings. That way, the name makes its intended use somewhat clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much clearer yes! Done :)

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

Thanks!

@BurntSushi BurntSushi merged commit 5f21fe2 into astral-sh:main Feb 11, 2026
46 checks passed
@Hugo-Polloli Hugo-Polloli deleted the virtual-files-settings branch March 1, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inlay hint settings ignored for virtual files

3 participants