Repository navigation
fix(configuration): resolve root paths against the config folder, apply extends transitively, replace on reload - #915
Open
psteinroe wants to merge 4 commits into
Conversation
…ly extends transitively, replace on reload Relative paths and globs of the root configuration are resolved against the folder of the configuration file instead of the working directory of the process. An extended file's own extends are applied too, with cycle detection and a depth limit. The LSP and the CLI replace the root settings on reload, so removed sections go back to their defaults; the wasm format call keeps merging.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #908 → #902 → #895 → #881. Must merge after #881.
Three ways the root configuration didn't behave like the docs or like a nested configuration.
Relative paths resolved against the process's working directory (C7).
update_settingsgotworkspace_directory: fs.working_directory()from both the LSP and the CLI, andLoadedConfiguration::directory_pathwas dropped. With the server started outside the workspace (Neovim from another cwd, the daemon, any workspace folder but the first) orcheckrun from a subfolder, the rootmigrations.migrationsDir,files.ignore/includeand linter globs pointed at the wrong folder, while nested configurations already used their own folder:Now both pass the folder of the configuration file (the project folder for the user configuration or no configuration). The CLI also uses that folder as the VCS base, like the LSP already did.
extendswas one level deep (C10). The pattern #881 documents, a nested file with"extends": ["../../postgres-language-server.jsonc"], lost whatever the root itself extended (a shared file, the user configuration). Extended files' ownextendsare now applied first, resolved relative to the extended file. A cycle fails withThe configuration files extend each other: a -> b -> a, and more than 10 levels fail too.Reloading merged into the old root settings (C11, self-noted in #881). Removing
"linter": { "rules": { "banDropColumn": "error" } }from the file kept theerroruntil a restart.UpdateSettingsParamsgetsreplace(#[serde(default)], sofalsefor existing JSON clients). The LSP and the CLI replace: the settings are rebuilt from the defaults, and only swapped in if the configuration applies, so a broken file keeps the previous settings. The wasmformatcall keeps merging, since it only sends the formatter section.Changelog (behaviour changes)
check/formatrun from a subfolder of the configuration and editors whose server runs elsewhere. The CLI also looks for.gitignorefrom the configuration folder.extendsapplies theextendsof extended files; cycles and chains deeper than 10 are errors.UpdateSettingsParams.replaceis new in the workspace protocol (optional, defaults to merging).Tests
configuration::tests:extends_is_applied_transitively(three levels, owndb.databasewins, inheriteddb.hostkept, extended files listed),extends_fails_on_a_cycle,extends_fails_when_too_deep.pgls_workspace:updating_the_settings_replaces_or_merges_them.relative_paths_of_the_root_configuration_are_relative_to_its_folder(server cwd outside the workspace, root and nestedmigrationsDir),a_section_removed_from_the_configuration_goes_back_to_its_defaults.relative_paths_are_relative_to_the_configuration_file(check ../migrations/0009_later.sqlfromsub/).just gen-lintregenerated bothbackend-jsonrpcworkspace.tsfiles.Not covered
files.ignoreglobs still aren't anchored to the configuration folder by the matcher (pre-existing, see feat: apply the nearest configuration file to each file (nested configs) #881).