Skip to content

Fix setting selection for multi folder workspace#24819

Merged
MichaReiser merged 2 commits intomainfrom
micha/multiworkspace-settings
Apr 24, 2026
Merged

Fix setting selection for multi folder workspace#24819
MichaReiser merged 2 commits intomainfrom
micha/multiworkspace-settings

Conversation

@MichaReiser
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser commented Apr 24, 2026

Summary

This PR fixes an issue where the server picked the settings of the wrong workspace folder
in a multi workspace folder project:

The issue is that we used next_back to find the correct settings in the settings map.

There are two open workspace folders:

/X
/X/external/Y

When resolving the settings for /X/systemtests/tests/common/fakes/wus.py,
range(..).next_back() returned the settings of /X/external/Y instead of /X because
/X/systemtests/tests/common/fakes/wus.py sorts after /X/external/y, even though
it isn't a prefix of /X/systemtest.

This PR fixes the issue by using rfind to find the longest match with a shared prefix.

I plan to submit a similar PR for ty_server.

Fixes astral-sh/ruff-vscode#925

Test Plan

Added E2E test

@MichaReiser MichaReiser added bug Something isn't working server Related to the LSP server labels Apr 24, 2026
@MichaReiser MichaReiser marked this pull request as draft April 24, 2026 20:36
@MichaReiser MichaReiser marked this pull request as ready for review April 24, 2026 20:39
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Apr 24, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser merged commit 7089451 into main Apr 24, 2026
44 checks passed
@MichaReiser MichaReiser deleted the micha/multiworkspace-settings branch April 24, 2026 22:49
carljm added a commit to tamird/ruff that referenced this pull request Apr 27, 2026
* main: (248 commits)
  [ty] bump conformance suite commit (astral-sh#24848)
  [ty] Pass unmapped type variables to `SpecializationBuilder::build_with` (astral-sh#24809)
  [ty] Avoid bookkeeping for unannotated functions (astral-sh#24842)
  [ty] Optimize signature checking based on number of arguments (astral-sh#24674)
  [ty] Avoid eagerly inferring legacy generic context (astral-sh#24841)
  [ty] Skip decorator inference for undecorated functions (astral-sh#24839)
  [ty] solve unions against generic protocols (astral-sh#24837)
  [ty] Lazily allocate parameter type builders (astral-sh#24838)
  [ty] Lazily compute call argument fallbacks (astral-sh#24836)
  [ty] Avoid collecting type context callables (astral-sh#24835)
  Bump ecosystem-analyzer to e7576e6 (astral-sh#24834)
  [ty] Support basic narrowing with aliased conditional expressions (astral-sh#24302)
  [ty] Fix project and workspace selection (astral-sh#24824)
  [ty] Fix missing memory usage attributes (astral-sh#24823)
  Fix setting selection for multi folder workspace (astral-sh#24819)
  Improve diagnostics for implicit calls to a possibly unbound unary operator. (astral-sh#24816)
  [ty] Update review pool (astral-sh#24818)
  Bump 0.15.12 (astral-sh#24815)
  [ty] Complete support for more detailed diagnostics on possibly unbound errors from implicit dunder calls against unions. (astral-sh#24676)
  Implement `#ruff:file-ignore` file-level suppressions (astral-sh#23599)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server Related to the LSP server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-root workspace makes Ruff use wrong settings

3 participants