diff --git a/package.json b/package.json index 5d49d8210d3..c8b077638e5 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/interactive-window/interactiveWindowProvider.ts b/src/interactive-window/interactiveWindowProvider.ts index 2bd5966b740..313b688d0da 100644 --- a/src/interactive-window/interactiveWindowProvider.ts +++ b/src/interactive-window/interactiveWindowProvider.ts @@ -121,6 +121,10 @@ export class InteractiveWindowProvider implements IInteractiveWindowProvider, IE tab, Uri.parse(iw.inputBoxUriString) ); + + this.updateExecuteConfigSetting().catch((ex) => + logger.warn('Failed to update executeWithShiftEnter setting', ex) + ); result.notifyConnectionReset(); this._windows.push(result); @@ -166,10 +170,36 @@ export class InteractiveWindowProvider implements IInteractiveWindowProvider, IE } await result.ensureInitialized(); + this.updateExecuteConfigSetting().catch((ex) => + logger.warn('Failed to update executeWithShiftEnter setting', ex) + ); return result; } + private async updateExecuteConfigSetting() { + const updatedExecuteConfigKey = 'updatedExecuteInteractiveConfig'; + const updatedExecuteConfig = this.globalMemento.get(updatedExecuteConfigKey); + if (updatedExecuteConfig) { + // We've already updated the setting, don't change it again if the user removed it + return; + } + + const config = workspace.getConfiguration('interactiveWindow'); + const inspected = config.inspect('executeWithShiftEnter'); + + if ( + inspected?.workspaceValue === undefined && + inspected?.workspaceFolderValue === undefined && + inspected?.globalValue === undefined + ) { + // Update the setting to execute with shift+enter if the user has not set it explicitly + // This is to ensure that the behavior stays consistent, but we should only keep doing this for a single release cycle + await config.update('executeWithShiftEnter', true, ConfigurationTarget.Global); + await this.globalMemento.update(updatedExecuteConfigKey, undefined); + } + } + /** * Given a text document, return the associated interactive window if one exists. * @param owner The URI of a text document which may be associated with an interactive window.