Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
04e0b34
Fix path
May 6, 2020
9297d96
Merge branch 'master' of https://github.com/Microsoft/vscode-python
May 6, 2020
9f3d5ac
Merge branch 'master' of https://github.com/Microsoft/vscode-python
May 11, 2020
e8640a2
Partial
May 12, 2020
c0211a7
Fix remaining settings
May 13, 2020
8a6e122
Keep names for now
May 14, 2020
5de66a0
Fix default
May 14, 2020
04b14b5
Restore names
May 15, 2020
7646a81
Update url
May 15, 2020
058e032
NAmes
May 15, 2020
4c1fb81
Formatting
May 16, 2020
8120a4d
Formatting
May 16, 2020
10ee2db
Test fixes
May 16, 2020
109f9c5
Test fixes
May 18, 2020
268c3a6
Test fixes
May 18, 2020
794c5f3
Linting test fixes
May 19, 2020
2c6d70a
Linting tests
May 19, 2020
a272c41
Unused var
May 19, 2020
24754cb
Restore inspection
May 19, 2020
18c435c
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
May 19, 2020
76b47ba
Add news
May 19, 2020
d55a417
MErge issues
May 20, 2020
9417dfd
Merge issues
May 20, 2020
66842c3
Wor around CI
May 20, 2020
ef6286f
Remove client reference
May 20, 2020
88bde1b
Use direct import in smoke tests
May 20, 2020
2d4df2f
Fix smoke tests
May 20, 2020
683f00f
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
May 20, 2020
c684bd1
Fix linter test
May 21, 2020
f9b183c
Avoid imports in smoke tests
May 21, 2020
1f6813c
PR feedback
May 21, 2020
54742a3
Add jediEnabled/languageServer fixup with tests
May 22, 2020
f105072
Update LS type
May 22, 2020
93c2ccd
Use json-parser for comments
May 22, 2020
91c1b71
Leave existing languageServer setting value alone
May 22, 2020
22f1e8f
Update src/test/.vscode/settings.json
May 26, 2020
729c707
PR feedback
May 26, 2020
3e1bac4
Merge branch 'settings' of https://github.com/MikhailArkhipov/vscode-…
May 26, 2020
7d78908
Put test back
May 26, 2020
c9e7e7d
Merge branch 'master' of https://github.com/Microsoft/vscode-python i…
May 26, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/1_ds_bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _Please provide as much info as you readily know_
- **Jupyter server running:** Local | Remote | N/A
- **Extension version:** 20YY.MM.#####-xxx
- **VS Code version:** #.##
- **Setting python.jediEnabled:** true | false
- **Setting python.languageServer:** Jedi | Microsoft | None
- **Python and/or Anaconda version:** #.#.#
- **OS:** Windows | Mac | Linux (distro):
- **Virtual environment:** conda | venv | virtualenv | N/A | ...
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/2_bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ labels: classify, type-bug
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): XXX
- Relevant/affected Python packages and their versions: XXX
- Relevant/affected Python-related VS Code extensions and their versions: XXX
- Jedi or Language Server? (i.e. what is `"python.jediEnabled"` set to; more info #3977): XXX
Comment thread
ericsnowcurrently marked this conversation as resolved.
- Value of the `python.languageServer` setting: XXX

## Expected behaviour
Expand Down
2 changes: 1 addition & 1 deletion .github/release_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- [ ] Change the version in [`package.json`](https://github.com/Microsoft/vscode-python/blob/master/package.json) from a `-dev` suffix to `-rc` (🤖)
- [ ] Run `npm install` to make sure [`package-lock.json`](https://github.com/Microsoft/vscode-python/blob/master/package.json) is up-to-date (🤖)
- [ ] Update `requirements.txt` to point to latest release version of [ptvsd](https://github.com/microsoft/ptvsd).
- [ ] Update `languageServerVersion` in `package.json` to point to the latest version (???) of [the Language Server](https://github.com/Microsoft/python-language-server).
- [ ] Update `languageServerVersion` in `package.json` to point to the latest version of the [Language Server](https://github.com/Microsoft/python-language-server).
- [ ] Update [`CHANGELOG.md`](https://github.com/Microsoft/vscode-python/blob/master/CHANGELOG.md) (🤖)
- [ ] Run [`news`](https://github.com/Microsoft/vscode-python/tree/master/news) (typically `python news --final --update CHANGELOG.md | code-insiders -`)
- [ ] Copy over the "Thanks" section from the previous release
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"source.fixAll.eslint": true,
"source.fixAll.tslint": true
},
"python.jediEnabled": false,
"python.languageServer": "Microsoft",
"python.analysis.logLevel": "Trace",
"python.analysis.downloadChannel": "beta",
"python.linting.pylintEnabled": false,
Expand Down
2 changes: 1 addition & 1 deletion news/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.jediEnabled": false,
"python.languageServer": "Microsoft",
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"python.testing.pytestArgs": ["."],
Expand Down
1 change: 1 addition & 0 deletions news/1 Enhancements/7010.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed `python.jediEnabled` setting in favor of `python.languageServer`. Instead of `"python.jediEnabled": true` please use `"python.languageServer": "Jedi"`.
1 change: 1 addition & 0 deletions news/1 Enhancements/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Changes that add new features.

6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2121,12 +2121,6 @@
"description": "Whether to install Python modules globally when not using an environment.",
"scope": "resource"
},
"python.jediEnabled": {
"type": "boolean",
"default": true,
"description": "Enables Jedi as IntelliSense engine instead of Microsoft Python Analysis Engine.",
"scope": "resource"
},
"python.jediMemoryLimit": {
"type": "number",
"default": 0,
Expand Down
43 changes: 24 additions & 19 deletions src/client/activation/activationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
LanguageServerType
} from './types';

const jediEnabledSetting: keyof IPythonSettings = 'jediEnabled';
const languageServerSetting: keyof IPythonSettings = 'languageServer';
const workspacePathNameForGlobalWorkspaces = '';

Expand Down Expand Up @@ -130,32 +129,37 @@ export class LanguageServerExtensionActivationService
}
}
@swallowExceptions('Send telemetry for Language Server current selection')
public async sendTelemetryForChosenLanguageServer(jediEnabled: boolean): Promise<void> {
const state = this.stateFactory.createGlobalPersistentState<boolean | undefined>('SWITCH_LS', undefined);
if (typeof state.value !== 'boolean') {
await state.updateValue(jediEnabled);
public async sendTelemetryForChosenLanguageServer(languageServer: LanguageServerType): Promise<void> {
const state = this.stateFactory.createGlobalPersistentState<LanguageServerType | undefined>(
'SWITCH_LS',
undefined
);
if (typeof state.value !== 'string') {
await state.updateValue(languageServer);
}
if (state.value !== jediEnabled) {
await state.updateValue(jediEnabled);
if (state.value !== languageServer) {
await state.updateValue(languageServer);
sendTelemetryEvent(EventName.PYTHON_LANGUAGE_SERVER_CURRENT_SELECTION, undefined, {
switchTo: jediEnabled
switchTo: languageServer
});
} else {
sendTelemetryEvent(EventName.PYTHON_LANGUAGE_SERVER_CURRENT_SELECTION, undefined, {
lsStartup: jediEnabled
lsStartup: languageServer
});
}
}

/**
* Checks if user has not manually set `jediEnabled` setting
* Checks if user does not have any `languageServer` setting set.
* @param resource
* @returns `true` if user has NOT manually added the setting and is using default configuration, `false` if user has `jediEnabled` setting added
* @returns `true` if user is using default configuration, `false` if user has `languageServer` setting added.
*/
public isJediUsingDefaultConfiguration(resource: Resource): boolean {
const settings = this.workspaceService.getConfiguration('python', resource).inspect<boolean>('jediEnabled');
const settings = this.workspaceService
.getConfiguration('python', resource)
.inspect<LanguageServerType>('languageServer');
if (!settings) {
traceError('WorkspaceConfiguration.inspect returns `undefined` for setting `python.jediEnabled`');
traceError('WorkspaceConfiguration.inspect returns `undefined` for setting `python.languageServer`');
return false;
}
return (
Expand All @@ -170,19 +174,21 @@ export class LanguageServerExtensionActivationService
* @returns `true` if user is using jedi, `false` if user is using language server
*/
public useJedi(): boolean {
// Check if `languageServer` setting is missing (default configuration).
if (this.isJediUsingDefaultConfiguration(this.resource)) {
// If user is assigned to an experiment (i.e. use LS), return false.
if (this.abExperiments.inExperiment(LSEnabled)) {
return false;
}
// Send telemetry if user is in control group
this.abExperiments.sendTelemetryIfInExperiment(LSControl);
return true; // Do use Jedi as it is default.
}
// Configuration is non-default, so `languageServer` should be present.
const configurationService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
let enabled = configurationService.getSettings(this.resource).jediEnabled;
const languageServerType = configurationService.getSettings(this.resource).languageServer;
enabled = enabled || languageServerType === LanguageServerType.Jedi;
this.sendTelemetryForChosenLanguageServer(enabled).ignoreErrors();
return enabled;
const lstType = configurationService.getSettings(this.resource).languageServer;
this.sendTelemetryForChosenLanguageServer(lstType).ignoreErrors();
return lstType === LanguageServerType.Jedi;
}

protected async onWorkspaceFoldersChanged() {
Expand Down Expand Up @@ -296,7 +302,6 @@ export class LanguageServerExtensionActivationService
? this.workspaceService.workspaceFolders!.map((workspace) => workspace.uri)
: [undefined];
if (
workspacesUris.findIndex((uri) => event.affectsConfiguration(`python.${jediEnabledSetting}`, uri)) === -1 &&
workspacesUris.findIndex((uri) => event.affectsConfiguration(`python.${languageServerSetting}`, uri)) === -1
) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ import { inject, injectable } from 'inversify';
import { IApplicationEnvironment } from '../../common/application/types';
import { IServiceContainer } from '../../ioc/types';
import { LanguageServerFolderService } from '../common/languageServerFolderService';
import { DotNetLanguageServerFolder } from '../types';

// Must match languageServerVersion* keys in package.json
const DotNetLanguageServerMinVersionKey = 'languageServerVersion';

@injectable()
export class DotNetLanguageServerFolderService extends LanguageServerFolderService {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super(serviceContainer, 'languageServer');
super(serviceContainer, DotNetLanguageServerFolder);
}

protected getMinimalLanguageServerVersion(): string {
let minVersion = '0.0.0';
try {
const appEnv = this.serviceContainer.get<IApplicationEnvironment>(IApplicationEnvironment);
if (appEnv) {
minVersion = appEnv.packageJson.languageServerVersion as string;
minVersion = appEnv.packageJson[DotNetLanguageServerMinVersionKey] as string;
}
// tslint:disable-next-line: no-empty
} catch {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances do you expect this to fail? It would probably make sense to log the error (e.g. with traceVerbose()).

Expand Down
3 changes: 2 additions & 1 deletion src/client/activation/node/languageServerFolderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import { inject, injectable } from 'inversify';
import { IServiceContainer } from '../../ioc/types';
import { LanguageServerFolderService } from '../common/languageServerFolderService';
import { NodeLanguageServerFolder } from '../types';

@injectable()
export class NodeLanguageServerFolderService extends LanguageServerFolderService {
constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
super(serviceContainer, 'nodeLanguageServer');
super(serviceContainer, NodeLanguageServerFolder);
}

protected getMinimalLanguageServerVersion(): string {
Expand Down
3 changes: 3 additions & 0 deletions src/client/activation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export enum LanguageServerType {
None = 'None'
}

export const DotNetLanguageServerFolder = 'languageServer';
export const NodeLanguageServerFolder = 'nodeLanguageServer';

// tslint:disable-next-line: interface-name
export interface DocumentHandler {
handleOpen(document: TextDocument): void;
Expand Down
21 changes: 9 additions & 12 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class PythonSettings implements IPythonSettings {
}
private static pythonSettings: Map<string, PythonSettings> = new Map<string, PythonSettings>();
public downloadLanguageServer = true;
public jediEnabled = true;
public jediPath = '';
public jediMemoryLimit = 1024;
public envFile = '';
Expand Down Expand Up @@ -223,27 +222,25 @@ export class PythonSettings implements IPythonSettings {
this.downloadLanguageServer = systemVariables.resolveAny(
pythonSettings.get<boolean>('downloadLanguageServer', true)
)!;
this.jediEnabled = systemVariables.resolveAny(pythonSettings.get<boolean>('jediEnabled', true))!;
this.autoUpdateLanguageServer = systemVariables.resolveAny(
pythonSettings.get<boolean>('autoUpdateLanguageServer', true)
)!;
if (this.jediEnabled) {
// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
this.jediPath = systemVariables.resolveAny(pythonSettings.get<string>('jediPath'))!;
if (typeof this.jediPath === 'string' && this.jediPath.length > 0) {
this.jediPath = getAbsolutePath(systemVariables.resolveAny(this.jediPath), workspaceRoot);
} else {
this.jediPath = '';
}
this.jediMemoryLimit = pythonSettings.get<number>('jediMemoryLimit')!;
}

let ls = pythonSettings.get<LanguageServerType>('languageServer');
if (!ls) {
ls = LanguageServerType.Jedi;
}
this.languageServer = systemVariables.resolveAny(ls)!;

// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
this.jediPath = systemVariables.resolveAny(pythonSettings.get<string>('jediPath'))!;
if (typeof this.jediPath === 'string' && this.jediPath.length > 0) {
this.jediPath = getAbsolutePath(systemVariables.resolveAny(this.jediPath), workspaceRoot);
} else {
this.jediPath = '';
}
this.jediMemoryLimit = pythonSettings.get<number>('jediMemoryLimit')!;

const envFileSetting = pythonSettings.get<string>('envFile');
this.envFile = systemVariables.resolveAny(envFileSetting)!;
sendSettingTelemetry(this.workspace, envFileSetting);
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/featureDeprecationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const deprecatedFeatures: DeprecatedFeatureInfo[] = [
{
doNotDisplayPromptStateKey: 'SHOW_DEPRECATED_FEATURE_PROMPT_FOR_AUTO_COMPLETE_PRELOAD_MODULES',
message:
"The setting 'python.autoComplete.preloadModules' is deprecated, please consider using the new Language Server ('python.jediEnabled = false').",
"The setting 'python.autoComplete.preloadModules' is deprecated, please consider using Microsoft Language Server ('python.languageServer' setting).",
moreInfoUrl: 'https://github.com/Microsoft/vscode-python/issues/1704',
setting: { setting: 'autoComplete.preloadModules' }
}
Expand Down
1 change: 0 additions & 1 deletion src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export interface IPythonSettings {
readonly poetryPath: string;
readonly insidersChannel: ExtensionChannels;
readonly downloadLanguageServer: boolean;
readonly jediEnabled: boolean;
readonly jediPath: string;
readonly jediMemoryLimit: number;
readonly devOptions: string[];
Expand Down
12 changes: 9 additions & 3 deletions src/client/languageServices/proposeLanguageServerBanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { inject, injectable } from 'inversify';
import { ConfigurationTarget } from 'vscode';
import { LanguageServerType } from '../activation/types';
import { IApplicationShell } from '../common/application/types';
import '../common/extensions';
import { IConfigurationService, IPersistentStateFactory, IPythonExtensionBanner } from '../common/types';
Expand Down Expand Up @@ -82,7 +83,7 @@ export class ProposeLanguageServerBanner implements IPythonExtensionBanner {
const response = await this.appShell.showInformationMessage(this.bannerMessage, ...this.bannerLabels);
switch (response) {
case this.bannerLabels[ProposeLSLabelIndex.Yes]: {
await this.enableNewLanguageServer();
await this.enableLanguageServer();
await this.disable();
break;
}
Expand Down Expand Up @@ -111,7 +112,12 @@ export class ProposeLanguageServerBanner implements IPythonExtensionBanner {
.updateValue(false);
}

public async enableNewLanguageServer(): Promise<void> {
await this.configuration.updateSetting('jediEnabled', false, undefined, ConfigurationTarget.Global);
public async enableLanguageServer(): Promise<void> {
await this.configuration.updateSetting(
'languageServer',
LanguageServerType.Microsoft,
undefined,
ConfigurationTarget.Global
);
}
}
7 changes: 4 additions & 3 deletions src/client/linters/linterAvailability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { inject, injectable } from 'inversify';
import * as path from 'path';
import { Uri } from 'vscode';
import { LanguageServerType } from '../activation/types';
import { IApplicationShell, IWorkspaceService } from '../common/application/types';
import '../common/extensions';
import { IFileSystem } from '../common/platform/types';
Expand Down Expand Up @@ -133,11 +134,11 @@ export class AvailableLinterActivator implements IAvailableLinterActivator {
*
* This is a feature of the vscode-python extension that will become enabled once the
* Python Language Server becomes the default, replacing Jedi as the default. Testing
* the global default setting for `"python.jediEnabled": false` enables it.
* the global default setting for `"python.languageServer": !Jedi` enables it.
*
* @returns true if the global default for python.jediEnabled is false.
* @returns true if the global default for python.languageServer is not Jedi.
*/
public get isFeatureEnabled(): boolean {
return !this.configService.getSettings().jediEnabled;
return this.configService.getSettings().languageServer !== LanguageServerType.Jedi;
}
}
19 changes: 13 additions & 6 deletions src/client/linters/linterInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import * as path from 'path';
import { Uri } from 'vscode';
import { LanguageServerType } from '../activation/types';
import { IWorkspaceService } from '../common/application/types';
import { ExecutionInfo, IConfigurationService, Product } from '../common/types';
import { ILinterInfo, LinterId } from './types';
Expand Down Expand Up @@ -85,14 +86,20 @@ export class PylintLinterInfo extends LinterInfo {
super(Product.pylint, 'pylint', configService, configFileNames);
}
public isEnabled(resource?: Uri): boolean {
const enabled = super.isEnabled(resource);
if (!enabled || this.configService.getSettings(resource).jediEnabled) {
// We want to be sure the setting is not default since default is `true` and hence
// missing setting yields `true`. When setting is missing and LS is non-Jedi,
// we want default to be `false`. So inspection here makes sure we are not getting
// `true` because there is no setting and LS is active.
const enabled = super.isEnabled(resource); // Is it enabled by settings?
const usingJedi = this.configService.getSettings(resource).languageServer === LanguageServerType.Jedi;
if (usingJedi) {
// In Jedi case adhere to default behavior. Missing setting means `enabled`.
return enabled;
}
// If we're using new LS, then by default Pylint is disabled (unless the user provides a value).
const inspection = this.workspaceService
.getConfiguration('python', resource)
.inspect<boolean>('linting.pylintEnabled');
// If we're using LS, then by default Pylint is disabled unless user provided
// the value. We have to resort to direct inspection of settings here.
const configuration = this.workspaceService.getConfiguration('python', resource);
const inspection = configuration.inspect<boolean>(this.enabledSettingName);
if (
!inspection ||
(inspection.globalValue === undefined &&
Expand Down
9 changes: 5 additions & 4 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as stackTrace from 'stack-trace';
// tslint:disable-next-line: import-name
import TelemetryReporter from 'vscode-extension-telemetry/lib/telemetryReporter';

import { LanguageServerType } from '../activation/types';
import { DiagnosticCodes } from '../application/diagnostics/constants';
import { IWorkspaceService } from '../common/application/types';
import { AppinsightsKey, isTestExecution, PVSC_EXTENSION_ID } from '../common/constants';
Expand Down Expand Up @@ -1118,11 +1119,11 @@ export interface IEventNamePropertyMapping {
/**
* The startup value of the language server setting
*/
lsStartup?: boolean;
lsStartup?: LanguageServerType;
/**
* Used to track switch between LS and Jedi. Carries the final state after the switch.
* Used to track switch between language servers. Carries the final state after the switch.
*/
switchTo?: boolean;
switchTo?: LanguageServerType;
};
/**
* Telemetry event sent with details after attempting to download LS
Expand Down Expand Up @@ -1216,7 +1217,7 @@ export interface IEventNamePropertyMapping {
lsVersion?: string;
};
/**
* Telemetry event sent when user specified None to the language server and jediEnabled is false.
* Telemetry event sent when user specified None to the language server.
*/
[EventName.PYTHON_LANGUAGE_SERVER_NONE]: never | undefined;
/**
Expand Down
Loading