Skip to content

Commit

Permalink
allow users with shift+enter functional
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykim1 committed May 23, 2024
1 parent 0788e99 commit 910783b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1118,12 +1118,17 @@
{
"command": "python.execInREPL",
"key": "shift+enter",
"when": "config.python.REPL.sendToNativeREPL"
"when": "config.python.REPL.sendToNativeREPL && activeEditor != 'workbench.editor.interactive'"
},
{
"command": "python.execREPLShiftEnter",
"key": "shift+enter",
"when": "activeEditor == 'workbench.editor.interactive' && config.interactiveWindow.executeWithShiftEnter"
},
{
"command": "python.execInREPLEnter",
"key": "enter",
"when": "activeEditor == 'workbench.editor.interactive'"
"when": "!config.interactiveWindow.executeWithShiftEnter && activeEditor == 'workbench.editor.interactive'"
},
{
"command": "python.refreshTensorBoard",
Expand Down
1 change: 1 addition & 0 deletions src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export namespace Commands {
export const Exec_In_REPL = 'python.execInREPL';
export const Exec_Selection_In_Django_Shell = 'python.execSelectionInDjangoShell';
export const Exec_In_REPL_Enter = 'python.execInREPLEnter';
export const Exec_In_REPL_Shift_Enter = 'python.execREPLShiftEnter';
export const Exec_Selection_In_Terminal = 'python.execSelectionInTerminal';
export const GetSelectedInterpreterPath = 'python.interpreterPath';
export const InstallJupyter = 'python.installJupyter';
Expand Down
3 changes: 2 additions & 1 deletion src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { initializePersistentStateForTriggers } from './common/persistentState';
import { logAndNotifyOnLegacySettings } from './logging/settingLogs';
import { DebuggerTypeName } from './debugger/constants';
import { StopWatch } from './common/utils/stopWatch';
import { registerReplCommands, registerReplExecuteOnEnter } from './repl/replCommands';
import { registerReplCommands, registerReplExecuteOnEnter, registerReplExecuteOnShiftEnter } from './repl/replCommands';

export async function activateComponents(
// `ext` is passed to any extra activation funcs.
Expand Down Expand Up @@ -109,6 +109,7 @@ export function activateFeatures(ext: ExtensionState, _components: Components):

registerReplCommands(ext.disposables, interpreterService);
registerReplExecuteOnEnter(ext.disposables, interpreterService);
registerReplExecuteOnShiftEnter();
}

/// //////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions src/client/repl/replCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ export async function registerReplExecuteOnEnter(
);
}

export async function registerReplExecuteOnShiftEnter(): Promise<void> {
commands.registerCommand(Commands.Exec_In_REPL_Shift_Enter, async () => {
await commands.executeCommand(Commands.Exec_In_REPL_Enter);
});
}

function isMultiLineText(textEditor: TextEditor | undefined): boolean {
return (textEditor?.document?.lineCount ?? 0) > 1;
}

0 comments on commit 910783b

Please sign in to comment.