@@ -47,26 +47,47 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
4747
4848 const textDocument = await openFile ( file ) ;
4949 console . log ( `[smartSend.smoke] File opened in editor` ) ;
50+ console . log ( `[smartSend.smoke] Document has ${ textDocument . lineCount } lines` ) ;
51+ console . log ( `[smartSend.smoke] First 5 lines of file:` ) ;
52+ for ( let i = 0 ; i < Math . min ( 5 , textDocument . lineCount ) ; i ++ ) {
53+ console . log ( `[smartSend.smoke] Line ${ i } : ${ textDocument . lineAt ( i ) . text } ` ) ;
54+ }
5055
5156 if ( vscode . window . activeTextEditor ) {
5257 const myPos = new vscode . Position ( 0 , 0 ) ;
5358 vscode . window . activeTextEditor ! . selections = [ new vscode . Selection ( myPos , myPos ) ] ;
5459 console . log ( `[smartSend.smoke] Cursor set to position (0, 0)` ) ;
60+ console . log (
61+ `[smartSend.smoke] Current selection: "${ vscode . window . activeTextEditor . document . getText (
62+ vscode . window . activeTextEditor . selection ,
63+ ) } "`,
64+ ) ;
65+
66+ // Wait a bit for the editor state to settle
67+ console . log ( `[smartSend.smoke] Waiting 500ms for editor state to settle...` ) ;
68+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
5569 }
5670
5771 const terminalsBefore = vscode . window . terminals . length ;
5872 console . log ( `[smartSend.smoke] Number of terminals before execution: ${ terminalsBefore } ` ) ;
5973
74+ // On Windows, if there are existing terminals, wait a bit to ensure they're fully ready
75+ if ( terminalsBefore > 0 && process . platform === 'win32' ) {
76+ console . log ( `[smartSend.smoke] Waiting 3s for existing terminals to be ready on Windows...` ) ;
77+ await new Promise ( ( resolve ) => setTimeout ( resolve , 3000 ) ) ;
78+ }
79+
6080 const startTime = Date . now ( ) ;
61- console . log ( `[smartSend.smoke] Executing first 'python.execSelectionInTerminal' command at ${ new Date ( ) . toISOString ( ) } ` ) ;
81+ console . log (
82+ `[smartSend.smoke] Executing first 'python.execSelectionInTerminal' command at ${ new Date ( ) . toISOString ( ) } ` ,
83+ ) ;
6284
6385 await vscode . commands
6486 . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
6587 . then ( undefined , ( err ) => {
6688 console . error ( `[smartSend.smoke] First command failed: ${ err } ` ) ;
6789 assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
6890 } ) ;
69-
7091 const firstCmdTime = Date . now ( ) ;
7192 console . log ( `[smartSend.smoke] First command completed in ${ firstCmdTime - startTime } ms` ) ;
7293
@@ -80,8 +101,10 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
80101 // Windows may need more time for terminal to initialize and start executing
81102 const isWindows = process . platform === 'win32' ;
82103 const initialWaitTime = isWindows ? 2000 : 1000 ;
83- console . log ( `[smartSend.smoke] Waiting ${ initialWaitTime } ms for terminal to start processing (isWindows: ${ isWindows } )...` ) ;
84- await new Promise ( resolve => setTimeout ( resolve , initialWaitTime ) ) ;
104+ console . log (
105+ `[smartSend.smoke] Waiting ${ initialWaitTime } ms for terminal to start processing (isWindows: ${ isWindows } )...` ,
106+ ) ;
107+ await new Promise ( ( resolve ) => setTimeout ( resolve , initialWaitTime ) ) ;
85108
86109 // Verify the working directory matches expected
87110 const expectedDir = path . dirname ( outputFile ) ;
@@ -92,7 +115,8 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
92115 const checkIfFileHasBeenCreated = async ( ) => {
93116 checkCount ++ ;
94117 const exists = await fs . pathExists ( outputFile ) ;
95- if ( checkCount % 100 === 0 ) { // Log every 100 checks (~1 second)
118+ if ( checkCount % 100 === 0 ) {
119+ // Log every 100 checks (~1 second)
96120 const elapsed = Date . now ( ) - startTime ;
97121 console . log ( `[smartSend.smoke] File creation check #${ checkCount } at ${ elapsed } ms: ${ exists } ` ) ;
98122 }
0 commit comments