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