@@ -21,15 +21,15 @@ import { IServiceContainer } from '../../../client/ioc/types';
21
21
import { ICodeExecutionHelper } from '../../../client/terminals/types' ;
22
22
import { Commands , EXTENSION_ROOT_DIR } from '../../../client/common/constants' ;
23
23
import { EnvironmentType , PythonEnvironment } from '../../../client/pythonEnvironments/info' ;
24
- import { PYTHON_PATH } from '../../common' ;
24
+ import { PYTHON_PATH , getPythonSemVer } from '../../common' ;
25
25
import { Architecture } from '../../../client/common/utils/platform' ;
26
26
import { ProcessService } from '../../../client/common/process/proc' ;
27
27
import { l10n } from '../../mocks/vsc' ;
28
28
import { ReplType } from '../../../client/repl/types' ;
29
29
30
30
const TEST_FILES_PATH = path . join ( EXTENSION_ROOT_DIR , 'src' , 'test' , 'python_files' , 'terminalExec' ) ;
31
31
32
- suite ( 'REPL - Smart Send' , ( ) => {
32
+ suite ( 'REPL - Smart Send' , async ( ) => {
33
33
let documentManager : TypeMoq . IMock < IDocumentManager > ;
34
34
let applicationShell : TypeMoq . IMock < IApplicationShell > ;
35
35
@@ -168,67 +168,71 @@ suite('REPL - Smart Send', () => {
168
168
commandManager . verifyAll ( ) ;
169
169
} ) ;
170
170
171
- test ( 'Smart send should perform smart selection and move cursor' , async ( ) => {
172
- configurationService
173
- . setup ( ( c ) => c . getSettings ( TypeMoq . It . isAny ( ) ) )
174
- . returns ( {
175
- REPL : {
176
- REPLSmartSend : true ,
177
- } ,
178
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
- } as any ) ;
180
-
181
- const activeEditor = TypeMoq . Mock . ofType < TextEditor > ( ) ;
182
- const firstIndexPosition = new Position ( 0 , 0 ) ;
183
- const selection = TypeMoq . Mock . ofType < Selection > ( ) ;
184
- const wholeFileContent = await fs . readFile ( path . join ( TEST_FILES_PATH , `sample_smart_selection.py` ) , 'utf8' ) ;
185
-
186
- selection . setup ( ( s ) => s . anchor ) . returns ( ( ) => firstIndexPosition ) ;
187
- selection . setup ( ( s ) => s . active ) . returns ( ( ) => firstIndexPosition ) ;
188
- selection . setup ( ( s ) => s . isEmpty ) . returns ( ( ) => true ) ;
189
- activeEditor . setup ( ( e ) => e . selection ) . returns ( ( ) => selection . object ) ;
190
-
191
- documentManager . setup ( ( d ) => d . activeTextEditor ) . returns ( ( ) => activeEditor . object ) ;
192
- document . setup ( ( d ) => d . getText ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => wholeFileContent ) ;
193
- const actualProcessService = new ProcessService ( ) ;
194
-
195
- const { execObservable } = actualProcessService ;
196
-
197
- processService
198
- . setup ( ( p ) => p . execObservable ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
199
- . returns ( ( file , args , options ) => execObservable . apply ( actualProcessService , [ file , args , options ] ) ) ;
200
-
201
- const actualSmartOutput = await codeExecutionHelper . normalizeLines (
202
- 'my_dict = {' ,
203
- ReplType . terminal ,
204
- wholeFileContent ,
205
- ) ;
206
-
207
- // my_dict = { <----- smart shift+enter here
208
- // "key1": "value1",
209
- // "key2": "value2"
210
- // } <---- cursor should be here afterwards, hence offset 3
211
- commandManager
212
- . setup ( ( c ) => c . executeCommand ( 'cursorMove' , TypeMoq . It . isAny ( ) ) )
213
- . callback ( ( _ , arg2 ) => {
214
- assert . deepEqual ( arg2 , {
215
- to : 'down' ,
216
- by : 'line' ,
217
- value : 3 ,
218
- } ) ;
219
- return Promise . resolve ( ) ;
220
- } )
221
- . verifiable ( TypeMoq . Times . once ( ) ) ;
222
-
223
- commandManager
224
- . setup ( ( c ) => c . executeCommand ( 'cursorEnd' ) )
225
- . returns ( ( ) => Promise . resolve ( ) )
226
- . verifiable ( TypeMoq . Times . once ( ) ) ;
227
-
228
- const expectedSmartOutput = 'my_dict = {\n "key1": "value1",\n "key2": "value2"\n}\n' ;
229
- expect ( actualSmartOutput ) . to . be . equal ( expectedSmartOutput ) ;
230
- commandManager . verifyAll ( ) ;
231
- } ) ;
171
+ const pythonTestVersion = await getPythonSemVer ( ) ;
172
+
173
+ if ( pythonTestVersion && pythonTestVersion . minor < 13 ) {
174
+ test ( 'Smart send should perform smart selection and move cursor - Python < 3.13' , async ( ) => {
175
+ configurationService
176
+ . setup ( ( c ) => c . getSettings ( TypeMoq . It . isAny ( ) ) )
177
+ . returns ( {
178
+ REPL : {
179
+ REPLSmartSend : true ,
180
+ } ,
181
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
182
+ } as any ) ;
183
+
184
+ const activeEditor = TypeMoq . Mock . ofType < TextEditor > ( ) ;
185
+ const firstIndexPosition = new Position ( 0 , 0 ) ;
186
+ const selection = TypeMoq . Mock . ofType < Selection > ( ) ;
187
+ const wholeFileContent = await fs . readFile ( path . join ( TEST_FILES_PATH , `sample_smart_selection.py` ) , 'utf8' ) ;
188
+
189
+ selection . setup ( ( s ) => s . anchor ) . returns ( ( ) => firstIndexPosition ) ;
190
+ selection . setup ( ( s ) => s . active ) . returns ( ( ) => firstIndexPosition ) ;
191
+ selection . setup ( ( s ) => s . isEmpty ) . returns ( ( ) => true ) ;
192
+ activeEditor . setup ( ( e ) => e . selection ) . returns ( ( ) => selection . object ) ;
193
+
194
+ documentManager . setup ( ( d ) => d . activeTextEditor ) . returns ( ( ) => activeEditor . object ) ;
195
+ document . setup ( ( d ) => d . getText ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => wholeFileContent ) ;
196
+ const actualProcessService = new ProcessService ( ) ;
197
+
198
+ const { execObservable } = actualProcessService ;
199
+
200
+ processService
201
+ . setup ( ( p ) => p . execObservable ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
202
+ . returns ( ( file , args , options ) => execObservable . apply ( actualProcessService , [ file , args , options ] ) ) ;
203
+
204
+ const actualSmartOutput = await codeExecutionHelper . normalizeLines (
205
+ 'my_dict = {' ,
206
+ ReplType . terminal ,
207
+ wholeFileContent ,
208
+ ) ;
209
+
210
+ // my_dict = { <----- smart shift+enter here
211
+ // "key1": "value1",
212
+ // "key2": "value2"
213
+ // } <---- cursor should be here afterwards, hence offset 3
214
+ commandManager
215
+ . setup ( ( c ) => c . executeCommand ( 'cursorMove' , TypeMoq . It . isAny ( ) ) )
216
+ . callback ( ( _ , arg2 ) => {
217
+ assert . deepEqual ( arg2 , {
218
+ to : 'down' ,
219
+ by : 'line' ,
220
+ value : 3 ,
221
+ } ) ;
222
+ return Promise . resolve ( ) ;
223
+ } )
224
+ . verifiable ( TypeMoq . Times . once ( ) ) ;
225
+
226
+ commandManager
227
+ . setup ( ( c ) => c . executeCommand ( 'cursorEnd' ) )
228
+ . returns ( ( ) => Promise . resolve ( ) )
229
+ . verifiable ( TypeMoq . Times . once ( ) ) ;
230
+
231
+ const expectedSmartOutput = 'my_dict = {\n "key1": "value1",\n "key2": "value2"\n}\n' ;
232
+ expect ( actualSmartOutput ) . to . be . equal ( expectedSmartOutput ) ;
233
+ commandManager . verifyAll ( ) ;
234
+ } ) ;
235
+ }
232
236
233
237
// Do not perform smart selection when there is explicit selection
234
238
test ( 'Smart send should not perform smart selection when there is explicit selection' , async ( ) => {
0 commit comments