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

remove normalization through external python process #16419

Merged
merged 3 commits into from
Feb 3, 2025
Merged
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
144 changes: 0 additions & 144 deletions pythonFiles/normalizeSelection.py

This file was deleted.

11 changes: 1 addition & 10 deletions src/interactive-window/editor-integration/codewatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,7 @@ export class CodeWatcher implements ICodeWatcher {
return;
}

const normalize =
this.configService.getSettings(activeEditor.document.uri).normalizeSelectionForInteractiveWindow ??
true;
const normalizedCode = normalize
? await this.executionHelper.normalizeLines(codeToExecute!)
: codeToExecute;
if (!normalizedCode || normalizedCode.trim().length === 0) {
return;
}
await this.addCode(iw, normalizedCode, this.document.uri, activeEditor.selection.start.line);
await this.addCode(iw, codeToExecute, this.document.uri, activeEditor.selection.start.line);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ testing2`;
)
)
.returns(() => 'testing2');
helper.setup((h) => h.normalizeLines(TypeMoq.It.isAny())).returns((x: string) => Promise.resolve(x));

// Set up our expected calls to add code
activeInteractiveWindow
Expand Down Expand Up @@ -881,7 +880,6 @@ testing2`;
)
)
.returns(() => 'testing2');
helper.setup((h) => h.normalizeLines(TypeMoq.It.isAny())).returns((x: string) => Promise.resolve(x));

// Set up our expected calls to add code
activeInteractiveWindow
Expand Down
1 change: 0 additions & 1 deletion src/platform/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class JupyterSettings implements IWatchableJupyterSettings {
public notebookFileRoot: string = '';
public useDefaultConfigForJupyter: boolean = false;
public sendSelectionToInteractiveWindow: boolean = false;
public normalizeSelectionForInteractiveWindow: boolean = true;
public splitRunFileIntoCells: boolean = true;
public markdownRegularExpression: string = '';
public codeRegularExpression: string = '';
Expand Down
1 change: 0 additions & 1 deletion src/platform/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ export enum Telemetry {
PandasTooOld = 'DS_INTERNAL.SHOW_DATA_PANDAS_TOO_OLD',
PandasOK = 'DS_INTERNAL.SHOW_DATA_PANDAS_OK',
PandasInstallCanceled = 'DS_INTERNAL.SHOW_DATA_PANDAS_INSTALL_CANCELED',
DataScienceSettings = 'DS_INTERNAL.SETTINGS',
VariableExplorerVariableCount = 'DS_INTERNAL.VARIABLE_EXPLORER_VARIABLE_COUNT',
AddCellBelow = 'DATASCIENCE.ADD_CELL_BELOW',
GetPasswordFailure = 'DS_INTERNAL.GET_PASSWORD_FAILURE',
Expand Down
1 change: 0 additions & 1 deletion src/platform/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export interface IJupyterSettings {
readonly useDefaultConfigForJupyter: boolean;
readonly enablePythonKernelLogging: boolean;
readonly sendSelectionToInteractiveWindow: boolean;
readonly normalizeSelectionForInteractiveWindow: boolean;
readonly splitRunFileIntoCells: boolean;
readonly markdownRegularExpression: string;
readonly codeRegularExpression: string;
Expand Down
39 changes: 0 additions & 39 deletions src/platform/interpreter/internal/scripts/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,3 @@ import { EXTENSION_ROOT_DIR } from '../../../constants.node';

// It is simpler to hard-code it instead of using vscode.ExtensionContext.extensionPath.
export const _SCRIPTS_DIR = path.join(EXTENSION_ROOT_DIR, 'pythonFiles');
const SCRIPTS_DIR = _SCRIPTS_DIR;

// "scripts" contains everything relevant to the scripts found under
// the top-level "pythonFiles" directory. Each of those scripts has
// a function in this module which matches the script's filename.
// Each function provides the commandline arguments that should be
// used when invoking a Python executable, whether through spawn/exec
// or a terminal.
//
// Where relevant (nearly always), the function also returns a "parse"
// function that may be used to deserialize the stdout of the script
// into the corresponding object or objects. "parse()" takes a single
// string as the stdout text and returns the relevant data.
//
// Some of the scripts are located in subdirectories of "pythonFiles".
// For each of those subdirectories there is a sub-module where
// those scripts' functions may be found.
//
// In some cases one or more types related to a script are exported
// from the same module in which the script's function is located.
// These types typically relate to the return type of "parse()".
//
// ignored scripts:
// * install_debugpy.py (used only for extension development)

//============================
// normalizeSelection.py

export function normalizeSelection(): [string[], (out: string) => string] {
const script = path.join(SCRIPTS_DIR, 'normalizeSelection.py');
const args = [script];

function parse(out: string) {
// The text will be used as-is.
return out;
}

return [args, parse];
}
102 changes: 0 additions & 102 deletions src/platform/terminals/codeExecution/codeExecutionHelper.node.ts

This file was deleted.

8 changes: 3 additions & 5 deletions src/platform/terminals/codeExecution/codeExecutionHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import { PYTHON_LANGUAGE } from '../../common/constants';
import { ICodeExecutionHelper } from '../types';
import { noop } from '../../common/utils/misc';
import { dedentCode } from '../../common/helpers';
import { injectable } from 'inversify';

/**
* Handles trimming code sent to a terminal so it actually runs.
*/
export class CodeExecutionHelperBase implements ICodeExecutionHelper {
public async normalizeLines(code: string, _resource?: Uri): Promise<string> {
return code;
}

@injectable()
export class CodeExecutionHelper implements ICodeExecutionHelper {
public async getFileToExecute(): Promise<Uri | undefined> {
const activeEditor = window.activeTextEditor;
if (!activeEditor) {
Expand Down
Loading