@@ -21,7 +21,7 @@ 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' ;
@@ -168,67 +168,72 @@ suite('REPL - Smart Send', async () => {
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 pythonVersion = await getPythonSemVer ( ) ;
172
+ console . log ( 'Just printed pythoNVersion: \n' ) ;
173
+ console . log ( pythonVersion ) ;
174
+ if ( pythonVersion && pythonVersion . minor < 13 ) {
175
+ test ( 'Smart send should perform smart selection and move cursor' , async ( ) => {
176
+ configurationService
177
+ . setup ( ( c ) => c . getSettings ( TypeMoq . It . isAny ( ) ) )
178
+ . returns ( {
179
+ REPL : {
180
+ REPLSmartSend : true ,
181
+ } ,
182
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
183
+ } as any ) ;
184
+
185
+ const activeEditor = TypeMoq . Mock . ofType < TextEditor > ( ) ;
186
+ const firstIndexPosition = new Position ( 0 , 0 ) ;
187
+ const selection = TypeMoq . Mock . ofType < Selection > ( ) ;
188
+ const wholeFileContent = await fs . readFile ( path . join ( TEST_FILES_PATH , `sample_smart_selection.py` ) , 'utf8' ) ;
189
+
190
+ selection . setup ( ( s ) => s . anchor ) . returns ( ( ) => firstIndexPosition ) ;
191
+ selection . setup ( ( s ) => s . active ) . returns ( ( ) => firstIndexPosition ) ;
192
+ selection . setup ( ( s ) => s . isEmpty ) . returns ( ( ) => true ) ;
193
+ activeEditor . setup ( ( e ) => e . selection ) . returns ( ( ) => selection . object ) ;
194
+
195
+ documentManager . setup ( ( d ) => d . activeTextEditor ) . returns ( ( ) => activeEditor . object ) ;
196
+ document . setup ( ( d ) => d . getText ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => wholeFileContent ) ;
197
+ const actualProcessService = new ProcessService ( ) ;
198
+
199
+ const { execObservable } = actualProcessService ;
200
+
201
+ processService
202
+ . setup ( ( p ) => p . execObservable ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
203
+ . returns ( ( file , args , options ) => execObservable . apply ( actualProcessService , [ file , args , options ] ) ) ;
204
+
205
+ const actualSmartOutput = await codeExecutionHelper . normalizeLines (
206
+ 'my_dict = {' ,
207
+ ReplType . terminal ,
208
+ wholeFileContent ,
209
+ ) ;
210
+
211
+ // my_dict = { <----- smart shift+enter here
212
+ // "key1": "value1",
213
+ // "key2": "value2"
214
+ // } <---- cursor should be here afterwards, hence offset 3
215
+ commandManager
216
+ . setup ( ( c ) => c . executeCommand ( 'cursorMove' , TypeMoq . It . isAny ( ) ) )
217
+ . callback ( ( _ , arg2 ) => {
218
+ assert . deepEqual ( arg2 , {
219
+ to : 'down' ,
220
+ by : 'line' ,
221
+ value : 3 ,
222
+ } ) ;
223
+ return Promise . resolve ( ) ;
224
+ } )
225
+ . verifiable ( TypeMoq . Times . once ( ) ) ;
226
+
227
+ commandManager
228
+ . setup ( ( c ) => c . executeCommand ( 'cursorEnd' ) )
229
+ . returns ( ( ) => Promise . resolve ( ) )
230
+ . verifiable ( TypeMoq . Times . once ( ) ) ;
231
+
232
+ const expectedSmartOutput = 'my_dict = {\n "key1": "value1",\n "key2": "value2"\n}\n' ;
233
+ expect ( actualSmartOutput ) . to . be . equal ( expectedSmartOutput ) ;
234
+ commandManager . verifyAll ( ) ;
235
+ } ) ;
236
+ }
232
237
233
238
// Do not perform smart selection when there is explicit selection
234
239
test ( 'Smart send should not perform smart selection when there is explicit selection' , async ( ) => {
0 commit comments