Skip to content

Commit 580d5f3

Browse files
committed
use iextensions in configsettings
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
1 parent 2807972 commit 580d5f3

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/client/common/configSettings.ts

+13-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ import { sendSettingTelemetry } from '../telemetry/envFileTelemetry';
2121
import { ITestingSettings } from '../testing/configuration/types';
2222
import { IWorkspaceService } from './application/types';
2323
import { WorkspaceService } from './application/workspace';
24-
import { DEFAULT_INTERPRETER_SETTING, isTestExecution } from './constants';
24+
import { DEFAULT_INTERPRETER_SETTING, isTestExecution, PYREFLY_EXTENSION_ID } from './constants';
2525
import {
2626
IAutoCompleteSettings,
2727
IDefaultLanguageServer,
2828
IExperiments,
29+
IExtensions,
2930
IInterpreterPathService,
3031
IInterpreterSettings,
3132
IPythonSettings,
@@ -140,6 +141,7 @@ export class PythonSettings implements IPythonSettings {
140141
workspace: IWorkspaceService,
141142
private readonly interpreterPathService: IInterpreterPathService,
142143
private readonly defaultLS: IDefaultLanguageServer | undefined,
144+
private readonly extensions: IExtensions,
143145
) {
144146
this.workspace = workspace || new WorkspaceService();
145147
this.workspaceRoot = workspaceFolder;
@@ -152,6 +154,7 @@ export class PythonSettings implements IPythonSettings {
152154
workspace: IWorkspaceService,
153155
interpreterPathService: IInterpreterPathService,
154156
defaultLS: IDefaultLanguageServer | undefined,
157+
extensions: IExtensions,
155158
): PythonSettings {
156159
workspace = workspace || new WorkspaceService();
157160
const workspaceFolderUri = PythonSettings.getSettingsUriAndTarget(resource, workspace).uri;
@@ -164,6 +167,7 @@ export class PythonSettings implements IPythonSettings {
164167
workspace,
165168
interpreterPathService,
166169
defaultLS,
170+
extensions,
167171
);
168172
PythonSettings.pythonSettings.set(workspaceFolderKey, settings);
169173
settings.onDidChange((event) => PythonSettings.debounceConfigChangeNotification(event));
@@ -275,8 +279,14 @@ export class PythonSettings implements IPythonSettings {
275279
userLS === 'Microsoft' ||
276280
!Object.values(LanguageServerType).includes(userLS as LanguageServerType)
277281
) {
278-
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.None;
279-
this.languageServerIsDefault = true;
282+
if (
283+
this.extensions.getExtension(PYREFLY_EXTENSION_ID) &&
284+
pythonSettings.get<WorkspaceConfiguration>('pyrefly')?.get<boolean>('disableLanguageServices') !== true) {
285+
this.languageServer = LanguageServerType.None;
286+
} else {
287+
this.languageServer = this.defaultLS?.defaultLSType ?? LanguageServerType.None;
288+
}
289+
this.languageServerIsDefault = true;
280290
} else if (userLS === 'JediLSP') {
281291
// Switch JediLSP option to Jedi.
282292
this.languageServer = LanguageServerType.Jedi;

src/client/common/configuration/service.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IServiceContainer } from '../../ioc/types';
88
import { IWorkspaceService } from '../application/types';
99
import { PythonSettings } from '../configSettings';
1010
import { isUnitTestExecution } from '../constants';
11-
import { IConfigurationService, IDefaultLanguageServer, IInterpreterPathService, IPythonSettings } from '../types';
11+
import { IConfigurationService, IDefaultLanguageServer, IExtensions, IInterpreterPathService, IPythonSettings } from '../types';
1212

1313
@injectable()
1414
export class ConfigurationService implements IConfigurationService {
@@ -29,12 +29,14 @@ export class ConfigurationService implements IConfigurationService {
2929
);
3030
const interpreterPathService = this.serviceContainer.get<IInterpreterPathService>(IInterpreterPathService);
3131
const defaultLS = this.serviceContainer.tryGet<IDefaultLanguageServer>(IDefaultLanguageServer);
32+
const extensions = this.serviceContainer.get<IExtensions>(IExtensions);
3233
return PythonSettings.getInstance(
3334
resource,
3435
InterpreterAutoSelectionService,
3536
this.workspaceService,
3637
interpreterPathService,
3738
defaultLS,
39+
extensions,
3840
);
3941
}
4042

0 commit comments

Comments
 (0)