Skip to content

Commit

Permalink
Remove includeInterpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jun 17, 2023
1 parent 92f212f commit bb1b525
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"scripts": {
"format": "prettier -w .",
"lint": "eslint src --ext ts",
"typecheck": "tsc --noEmit",
"tsc": "tsc --noEmit",
"package": "webpack --mode production --devtool source-map --config ./webpack.config.js",
"watch": "webpack --watch",
"vsce-package": "vsce package -o ruff.vsix",
Expand Down
6 changes: 3 additions & 3 deletions src/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ export async function restartServer(
_disposables = [];
}
const projectRoot = await getProjectRoot();
const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true);
const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot);

const newLSClient = await createServer(workspaceSetting, serverId, serverName, outputChannel, {
settings: await getExtensionSettings(serverId, true),
globalSettings: await getGlobalSettings(serverId, false),
settings: await getExtensionSettings(serverId),
globalSettings: await getGlobalSettings(serverId),
});
traceInfo(`Server: Start requested.`);
_disposables.push(
Expand Down
35 changes: 9 additions & 26 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ export interface ISettings {
fixAll: boolean;
}

export function getExtensionSettings(
namespace: string,
includeInterpreter?: boolean,
): Promise<ISettings[]> {
export function getExtensionSettings(namespace: string): Promise<ISettings[]> {
return Promise.all(
getWorkspaceFolders().map((w) => getWorkspaceSettings(namespace, w, includeInterpreter)),
getWorkspaceFolders().map((workspaceFolder) =>
getWorkspaceSettings(namespace, workspaceFolder),
),
);
}

Expand Down Expand Up @@ -65,16 +64,12 @@ export function getInterpreterFromSetting(namespace: string, scope?: Configurati
export async function getWorkspaceSettings(
namespace: string,
workspace: WorkspaceFolder,
includeInterpreter?: boolean,
): Promise<ISettings> {
const config = getConfiguration(namespace, workspace.uri);

let interpreter: string[] = [];
if (includeInterpreter) {
interpreter = getInterpreterFromSetting(namespace, workspace) ?? [];
if (interpreter.length === 0) {
interpreter = (await getInterpreterDetails(workspace.uri)).path ?? [];
}
let interpreter: string[] = getInterpreterFromSetting(namespace, workspace) ?? [];
if (interpreter.length === 0) {
interpreter = (await getInterpreterDetails(workspace.uri)).path ?? [];
}

return {
Expand All @@ -97,26 +92,14 @@ function getGlobalValue<T>(config: WorkspaceConfiguration, key: string, defaultV
return inspect?.globalValue ?? inspect?.defaultValue ?? defaultValue;
}

export async function getGlobalSettings(
namespace: string,
includeInterpreter?: boolean,
): Promise<ISettings> {
export async function getGlobalSettings(namespace: string): Promise<ISettings> {
const config = getConfiguration(namespace);

let interpreter: string[] = [];
if (includeInterpreter) {
interpreter = getGlobalValue<string[]>(config, "interpreter", []);
if (interpreter === undefined || interpreter.length === 0) {
interpreter = (await getInterpreterDetails()).path ?? [];
}
}

return {
cwd: process.cwd(),
workspace: process.cwd(),
args: getGlobalValue<string[]>(config, "args", []),
path: getGlobalValue<string[]>(config, "path", []),
interpreter: interpreter,
interpreter: [],
importStrategy: getGlobalValue<ImportStrategy>(config, "importStrategy", "fromEnvironment"),
run: getGlobalValue<Run>(config, `run`, "onType"),
enable: getGlobalValue<boolean>(config, `enable`, true),
Expand Down

0 comments on commit bb1b525

Please sign in to comment.