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

prompt to change back to previous IW execute keybinding #15679

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@
"key": "alt+enter",
"when": "editorTextFocus && !editorHasSelection && jupyter.hascodecells && !notebookEditorFocused"
},
{
"key": "shift+enter",
"when": "activeEditor == 'workbench.editor.interactive' && notebookKernel =~ /^ms-toolsai.jupyter\\// || activeEditor == 'workbench.editor.interactive' && !notebookKernel",
"command": "interactive.execute"
},
{
"key": "escape",
"when": "activeEditor == 'workbench.editor.interactive' && !editorHoverVisible && !suggestWidgetVisible && !isComposing && !inSnippetMode && !exceptionWidgetVisible && !selectionAnchorSet && !LinkedEditingInputVisible && !renameInputVisible && !editorHasSelection && !accessibilityHelpWidgetVisible && !breakpointWidgetVisible && !findWidgetVisible && !markersNavigationVisible && !parameterHintsVisible && !editorHasMultipleSelections && !notificationToastsVisible",
Expand Down
49 changes: 49 additions & 0 deletions src/notebooks/controllers/InteractiveExecutionPrompt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { ConfigurationTarget, NotebookCell, window, workspace } from 'vscode';
import { IConfigurationService } from '../../platform/common/types';

export class InteractiveExecutionPrompt {
private disabled = false;

constructor(private readonly configurationService: IConfigurationService) {}

public async checkToPrompt(cell: NotebookCell) {
if (this.disabled) {
return;
}
if (cell.notebook.notebookType === 'interactive' && !cell.metadata.interactive) {
const settings = this.configurationService.getSettings(cell.document.uri);
const config = workspace.getConfiguration('interactiveWindow');
const setting = config.get('executeWithShiftEnter');

// can we check if the keybinding for interactive.execute is set to 'enter'?
if (!settings.promptToChangeInteractiveExecute || setting === undefined || setting === true) {
return;
}

const response = await window.showInformationMessage(
'Change execute keyboard shortcut to shift+enter? (previous behavior)',
'shift+enter to execute',
'enter to execute'
);
switch (response) {
case 'shift+enter to execute': {
await config.update('executeWithShiftEnter', true, ConfigurationTarget.Global);
await this.configurationService.updateSetting('promptToChangeInteractiveExecute', false);
break;
}
case 'enter to execute': {
await this.configurationService.updateSetting('promptToChangeInteractiveExecute', false);
break;
}
default:
{
}

this.disabled = true;
}
}
}
}
5 changes: 5 additions & 0 deletions src/notebooks/controllers/vscodeNotebookController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import { getVersion } from '../../platform/interpreter/helpers';
import { getNotebookTelemetryTracker, trackControllerCreation } from '../../kernels/telemetry/notebookTelemetry';
import { IJupyterVariablesProvider } from '../../kernels/variables/types';
import type { INotebookMetadata } from '@jupyterlab/nbformat';
import { InteractiveExecutionPrompt } from './InteractiveExecutionPrompt';

/**
* Our implementation of the VSCode Notebook Controller. Called by VS code to execute cells in a notebook. Also displayed
Expand All @@ -103,6 +104,7 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
private readonly _onDidDispose = new EventEmitter<void>();
private readonly disposables: IDisposable[] = [];
private notebookKernels = new WeakMap<NotebookDocument, IKernel>();
private interactiveExecutionPrompt: InteractiveExecutionPrompt;
public readonly controller: NotebookController;
/**
* Used purely for testing purposes.
Expand Down Expand Up @@ -228,6 +230,7 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
this,
this.disposables
);
this.interactiveExecutionPrompt = new InteractiveExecutionPrompt(this.configuration);
}

private readonly restoredConnections = new WeakSet<NotebookDocument>();
Expand Down Expand Up @@ -367,6 +370,7 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
if (cells.length < 1) {
return;
}
await this.interactiveExecutionPrompt.checkToPrompt(cells[0]);
const tracker = getNotebookTelemetryTracker(notebook);
tracker?.cellExecutionCount(cells.length);
const telemetryTracker = tracker?.preExecuteCellTelemetry();
Expand Down Expand Up @@ -398,6 +402,7 @@ export class VSCodeNotebookController implements Disposable, IVSCodeNotebookCont
// Notebook is trusted. Continue to execute cells
await Promise.all(cells.map((cell) => this.executeCell(notebook, cell)));
}

private async onDidChangeSelectedNotebooks(event: { notebook: NotebookDocument; selected: boolean }) {
logger.ci(
`NotebookController selection event called for notebook ${event.notebook.uri.toString()} & controller ${
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 @@ -88,6 +88,7 @@ export class JupyterSettings implements IWatchableJupyterSettings {
public excludeUserSitePackages: boolean = false;
public enableExtendedPythonKernelCompletions: boolean = false;
public formatStackTraces: boolean = false;
public promptToChangeInteractiveExecute: boolean = true;
// Privates should start with _ so that they are not read from the settings.json
private _changeEmitter = new EventEmitter<void>();
private _workspaceRoot: Resource;
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 @@ -93,6 +93,7 @@ export interface IJupyterSettings {
readonly excludeUserSitePackages: boolean;
readonly enableExtendedPythonKernelCompletions: boolean;
readonly formatStackTraces: boolean;
readonly promptToChangeInteractiveExecute: boolean;
/**
* Trigger characters for Jupyter completion, per language.
* This excludes the trigger characters for python.
Expand Down
Loading