Skip to content

Commit

Permalink
interactive.execute keyboard shortcut migrated to core, configure for…
Browse files Browse the repository at this point in the history
… jupyter IW users (#15714)

* add the setting for jupyter IW users

* interactive.execute keybindings have moved to core, use global memento to only configure once
  • Loading branch information
amunger authored May 24, 2024
1 parent 235f388 commit b519e0a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
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
30 changes: 30 additions & 0 deletions src/interactive-window/interactiveWindowProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<boolean>(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<boolean>('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.
Expand Down

0 comments on commit b519e0a

Please sign in to comment.