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

Show warning and allow user to turn off smart send for deprecated Python code #22353

Merged
merged 31 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
faebdb6
detect user is on file with deprecated Python code
anthonykim1 Oct 26, 2023
14f9b64
send warning message if smart send deprecated py
anthonykim1 Oct 26, 2023
e1d203f
add setting
anthonykim1 Oct 26, 2023
c5ced54
switch repl and code order to normal
anthonykim1 Oct 26, 2023
bc74433
comply with linting error
anthonykim1 Oct 26, 2023
d0ad1fb
fix for test failing
anthonykim1 Nov 13, 2023
be70c44
comment out unused variables
anthonykim1 Nov 13, 2023
d0fd80d
try adding configService and new REPL setting
anthonykim1 Nov 13, 2023
59805ad
quit unused var warning
anthonykim1 Nov 13, 2023
d911459
add activeResourceService
anthonykim1 Nov 13, 2023
a29ecdd
clean up
anthonykim1 Nov 13, 2023
924f9e8
respect deprecated
anthonykim1 Nov 14, 2023
fe80e93
make a button that leed to change setting
anthonykim1 Nov 14, 2023
e23c504
Change message wording
anthonykim1 Nov 14, 2023
f6f8a4a
Change wording
anthonykim1 Nov 14, 2023
91ffe64
use commandManager rather than calling vs code
anthonykim1 Nov 15, 2023
93ab499
add commandManager
anthonykim1 Nov 15, 2023
972f144
remove systemVariable resolve
anthonykim1 Nov 15, 2023
05d4e7f
add warning message test
anthonykim1 Nov 15, 2023
4ebc502
fix typo
anthonykim1 Nov 16, 2023
9283d80
fix smoke test error
anthonykim1 Nov 16, 2023
4682545
button will actually change setting
anthonykim1 Nov 16, 2023
d3efb7c
Update description according to suggestion
anthonykim1 Nov 16, 2023
f4deb62
add traceInfo message
anthonykim1 Nov 16, 2023
4ba135f
Update src/client/terminals/codeExecution/terminalCodeExecution.ts
anthonykim1 Nov 17, 2023
1794700
touch up on warning message
anthonykim1 Nov 17, 2023
13eeb80
check condition on Disable button
anthonykim1 Nov 17, 2023
4fc0357
Update src/client/terminals/codeExecution/terminalCodeExecution.ts
anthonykim1 Nov 17, 2023
956ee20
put message and button in localize
anthonykim1 Nov 17, 2023
16021ee
lowercase enable
anthonykim1 Nov 18, 2023
7063648
enable for test
anthonykim1 Nov 18, 2023
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
Prev Previous commit
Next Next commit
send warning message if smart send deprecated py
  • Loading branch information
anthonykim1 committed Oct 26, 2023
commit 14f9b64646a18ca0fbc770ac44cace9e042a3d2b
21 changes: 12 additions & 9 deletions pythonFiles/normalizeSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
import textwrap
from typing import Iterable

script_dir = pathlib.Path(
"User/anthonykim/Desktop/vscode-python/pythonFiles/lib/python"
)
sys.path.append(os.fspath(script_dir))
import debugpy
# script_dir = pathlib.Path(
# "User/anthonykim/Desktop/vscode-python/pythonFiles/lib/python"
# )
# sys.path.append(os.fspath(script_dir))
# import debugpy

debugpy.connect(5678)
debugpy.breakpoint()
# debugpy.connect(5678)
# debugpy.breakpoint()


def split_lines(source):
Expand Down Expand Up @@ -168,8 +168,11 @@ def traverse_file(wholeFileContent, start_line, end_line, was_highlighted):
except Exception as old_python_code:
# Handle case where user is attempting to run code where file contains deprecated Python code.
# Somehow have to let typescript side know and show warning message. (TODO)
print(old_python_code)
return
# print(old_python_code)
return {
"normalized_smart_result": "deprecated",
"which_line_next": 0,
}

smart_code = ""
should_run_top_blocks = []
Expand Down
8 changes: 4 additions & 4 deletions src/client/terminals/codeExecution/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
const result = await normalizeOutput.promise;
const object = JSON.parse(result);

if (activeEditor?.selection) {
const lineOffset = object.nextBlockLineno - activeEditor!.selection.start.line - 1;
await this.moveToNextBlock(lineOffset, activeEditor);
}
// if (activeEditor?.selection) {
// const lineOffset = object.nextBlockLineno - activeEditor!.selection.start.line - 1;
// await this.moveToNextBlock(lineOffset, activeEditor);
// }

return parse(object.normalized);
} catch (ex) {
Expand Down
20 changes: 17 additions & 3 deletions src/client/terminals/codeExecution/terminalCodeExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@

import { inject, injectable } from 'inversify';
import * as path from 'path';
import { Disposable, Uri } from 'vscode';
import { Disposable, l10n, Uri } from 'vscode';
import { IWorkspaceService } from '../../common/application/types';
import { Commands } from '../../common/constants';
import '../../common/extensions';
import { IPlatformService } from '../../common/platform/types';
import { ITerminalService, ITerminalServiceFactory } from '../../common/terminal/types';
import { IConfigurationService, IDisposableRegistry, Resource } from '../../common/types';
import { Common } from '../../common/utils/localize';
import { showWarningMessage } from '../../common/vscodeApis/windowApis';
import { IInterpreterService } from '../../interpreter/contracts';
import { buildPythonExecInfo, PythonExecInfo } from '../../pythonEnvironments/exec';
import { ICodeExecutionService } from '../../terminals/types';
Expand Down Expand Up @@ -42,9 +45,20 @@ export class TerminalCodeExecutionProvider implements ICodeExecutionService {
if (!code || code.trim().length === 0) {
return;
}

if (code == 'deprecated') {
// If user is trying to smart send deprecated code show warning
await showWarningMessage(
l10n.t(
`You are attempting to run Smart Send on Python file with deprecated code, please
turn off smart send if you wish to always run line by line or explicitly select code
to force run [logs](command:${Commands.ViewOutput}) for more details.`,
anthonykim1 marked this conversation as resolved.
Show resolved Hide resolved
),
Common.learnMore,
);
} else {
await this.getTerminalService(resource).sendText(code);
}
await this.initializeRepl(resource);
await this.getTerminalService(resource).sendText(code);
}
public async initializeRepl(resource: Resource) {
const terminalService = this.getTerminalService(resource);
Expand Down
Loading