Skip to content

Commit

Permalink
Turn off string filtering for completions (#10137)
Browse files Browse the repository at this point in the history
* Turn off string filtering for completions

* Run test with jedi and without

* Using Ian's setting name instead. Changed wording

* Update message again and add link to kernel setting
  • Loading branch information
rchiodo authored May 25, 2022
1 parent 7f9c84d commit 51fad38
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 214 deletions.
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

Large diffs are not rendered by default.

0 comments on commit 51fad38

Please sign in to comment.