Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off string filtering for completions #10137

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions news/2 Fixes/8893.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix to provide autocomplete inside of quoted strings. This fix also enabled a setting to allow the use of Jedi for completions in a kernel, but should be used with caution. Jedi can hang the kernel preventing exeuction from happening.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,7 @@
},
"jupyter.pythonCompletionTriggerCharacters": {
"type": "string",
"default": ".%",
"default": ".%'\"",
"description": "Characters which trigger auto completion on a python jupyter kernel.",
"scope": "machine"
},
Expand All @@ -2000,6 +2000,12 @@
"default": false,
"description": "Add PYTHONNOUSERSITE to kernels before starting. This prevents global/user site-packages from being used in the PYTHONPATH of the kernel.",
"scope": "machine"
},
"jupyter.enableExtendedKernelCompletions": {
"type": "boolean",
"default": false,
"markdownDescription": "Enables Jedi support for extended IntelliSense completions in running Jupyter kernels (see this [setting](https://ipython.readthedocs.io/en/stable/config/options/terminal.html?highlight=use_jedi#configtrait-Completer.use_jedi)). This can greatly impact notebook cell execution performance. Use with caution.",
"scope": "machine"
}
}
},
Expand Down
5 changes: 0 additions & 5 deletions src/intellisense/pythonKernelCompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,6 @@ export function filterCompletions(
allowStringFilter &&
(triggerCharacter == "'" || triggerCharacter == '"' || positionInsideString(line, position));

// If inside of a string, filter out everything except file names
if (insideString) {
result = result.filter((r) => r.itemText.includes('.') || r.itemText.endsWith('/'));
}

traceInfoIfCI(`Jupyter completions filtering applied: ${insideString} on ${line}`);

// Update magics to have a much lower sort order than other strings.
Expand Down
4 changes: 3 additions & 1 deletion src/kernels/kernel.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@ export abstract class BaseKernel implements IKernel {
if (file) {
result.push(`__vsc_ipynb_file__ = "${file.replace(/\\/g, '\\\\')}"`);
}
result.push(CodeSnippets.DisableJedi);
if (!this.configService.getSettings(undefined).enableExtendedKernelCompletions) {
result.push(CodeSnippets.DisableJedi);
}

// For Python notebook initialize matplotlib
// Wrap this startup code in try except as it might fail
Expand Down
1 change: 1 addition & 0 deletions src/platform/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class JupyterSettings implements IWatchableJupyterSettings {
public logKernelOutputSeparately: boolean = false;
public poetryPath: string = '';
public excludeUserSitePackages: boolean = false;
public enableExtendedKernelCompletions: boolean = false;

public variableTooltipFields: IVariableTooltipFields = {
python: {
Expand Down
1 change: 1 addition & 0 deletions src/platform/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export interface IJupyterSettings {
readonly logKernelOutputSeparately: boolean;
readonly poetryPath: string;
readonly excludeUserSitePackages: boolean;
readonly enableExtendedKernelCompletions: boolean;
}

export interface IVariableTooltipFields {
Expand Down
2 changes: 1 addition & 1 deletion src/test/datascience/interactiveWindow.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { EXTENSION_ROOT_DIR } from '../../platform/constants.node';
type DebuggerType = 'VSCodePythonDebugger' | 'JupyterProtocolDebugger';
const debuggerTypes: DebuggerType[] = ['JupyterProtocolDebugger', 'VSCodePythonDebugger'];
debuggerTypes.forEach((debuggerType) => {
suite.only(`Interactive window debugger using ${debuggerType}`, async function () {
suite(`Interactive window debugger using ${debuggerType}`, async function () {
this.timeout(120_000);
let api: IExtensionTestApi;
const disposables: IDisposable[] = [];
Expand Down

Large diffs are not rendered by default.