Skip to content

Commit

Permalink
Allow Smart send with new REPL (#23638)
Browse files Browse the repository at this point in the history
Resolves: microsoft#23521
  • Loading branch information
anthonykim1 authored and DonJayamanne committed Jun 24, 2024
1 parent 7473a34 commit 49e2ed7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/client/extensionActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { TerminalProvider } from './providers/terminalProvider';
import { setExtensionInstallTelemetryProperties } from './telemetry/extensionInstallTelemetry';
import { registerTypes as tensorBoardRegisterTypes } from './tensorBoard/serviceRegistry';
import { registerTypes as commonRegisterTerminalTypes } from './terminals/serviceRegistry';
import { ICodeExecutionManager, ITerminalAutoActivation } from './terminals/types';
import { ICodeExecutionHelper, ICodeExecutionManager, ITerminalAutoActivation } from './terminals/types';
import { registerTypes as unitTestsRegisterTypes } from './testing/serviceRegistry';

// components
Expand Down Expand Up @@ -106,8 +106,8 @@ export function activateFeatures(ext: ExtensionState, _components: Components):
interpreterService,
pathUtils,
);

registerReplCommands(ext.disposables, interpreterService);
const executionHelper = ext.legacyIOC.serviceContainer.get<ICodeExecutionHelper>(ICodeExecutionHelper);
registerReplCommands(ext.disposables, interpreterService, executionHelper);
registerReplExecuteOnEnter(ext.disposables, interpreterService);
}

Expand Down
10 changes: 9 additions & 1 deletion src/client/repl/replCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Disposable } from 'vscode-jsonrpc';
import { Commands } from '../common/constants';
import { noop } from '../common/utils/misc';
import { IInterpreterService } from '../interpreter/contracts';
import { ICodeExecutionHelper } from '../terminals/types';
import { getNativeRepl } from './nativeRepl';
import {
executeInTerminal,
Expand All @@ -22,6 +23,7 @@ import {
export async function registerReplCommands(
disposables: Disposable[],
interpreterService: IInterpreterService,
executionHelper: ICodeExecutionHelper,
): Promise<void> {
disposables.push(
commands.registerCommand(Commands.Exec_In_REPL, async (uri: Uri) => {
Expand All @@ -40,7 +42,13 @@ export async function registerReplCommands(
if (activeEditor) {
const code = await getSelectedTextToExecute(activeEditor);
if (code) {
await nativeRepl.sendToNativeRepl(code);
// Smart Send
let wholeFileContent = '';
if (activeEditor && activeEditor.document) {
wholeFileContent = activeEditor.document.getText();
}
const normalizedCode = await executionHelper.normalizeLines(code!, wholeFileContent);
await nativeRepl.sendToNativeRepl(normalizedCode);
}
}
}
Expand Down

0 comments on commit 49e2ed7

Please sign in to comment.