Skip to content

Commit

Permalink
Implement setting to prioritize file configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
snowsignal committed Apr 25, 2024
1 parent de9f7da commit b3345c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@
"scope": "resource",
"type": ["integer", "null"]
},
"ruff.prioritizeFileConfiguration": {
"markdownDescription": "Whether to prioritize file configuration over configuration set in extension settings.",
"scope": "window",
"type": "boolean",
"default": false
},
"ruff.enableExperimentalFormatter": {
"default": false,
"markdownDescription": "Controls whether Ruff registers as capable of code formatting.",
Expand Down
8 changes: 8 additions & 0 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface ISettings {
format: Format;
exclude?: string[];
lineLength?: number;
prioritizeFileConfiguration?: boolean;
}

export function getExtensionSettings(namespace: string): Promise<ISettings[]> {
Expand Down Expand Up @@ -141,6 +142,7 @@ export async function getWorkspaceSettings(
showNotifications: config.get<string>("showNotifications") ?? "off",
exclude: config.get<string[]>("exclude"),
lineLength: config.get<number>("lineLength"),
prioritizeFileConfiguration: config.get<boolean>("prioritizeFileConfiguration") ?? false,
};
}

Expand Down Expand Up @@ -184,6 +186,11 @@ export async function getGlobalSettings(namespace: string): Promise<ISettings> {
showNotifications: getGlobalValue<string>(config, "showNotifications", "off"),
exclude: getOptionalGlobalValue<string[]>(config, "exclude"),
lineLength: getOptionalGlobalValue<number>(config, "lineLength"),
prioritizeFileConfiguration: getGlobalValue<boolean>(
config,
"prioritizeFileConfiguration",
false,
),
};
}

Expand Down Expand Up @@ -211,6 +218,7 @@ export function checkIfConfigurationChanged(
`${namespace}.format.preview`,
`${namespace}.exclude`,
`${namespace}.lineLength`,
`${namespace}.prioritizeFileConfiguration`,
// Deprecated settings (prefer `lint.args`, etc.).
`${namespace}.args`,
`${namespace}.run`,
Expand Down

0 comments on commit b3345c0

Please sign in to comment.