@@ -54,14 +54,18 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
5454 }
5555
5656 if ( vscode . window . activeTextEditor ) {
57- const myPos = new vscode . Position ( 0 , 0 ) ;
58- vscode . window . activeTextEditor ! . selections = [ new vscode . Selection ( myPos , myPos ) ] ;
59- 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- ) } "` ,
57+ // Select the entire file content to execute
58+ // The implementation of execSelectionInTerminal with empty selection only runs the current line,
59+ // not smart selection. So we need to select the actual code we want to execute.
60+ const document = vscode . window . activeTextEditor . document ;
61+ const fullRange = new vscode . Range (
62+ document . lineAt ( 0 ) . range . start ,
63+ document . lineAt ( document . lineCount - 1 ) . range . end ,
6464 ) ;
65+ vscode . window . activeTextEditor . selection = new vscode . Selection ( fullRange . start , fullRange . end ) ;
66+
67+ const selectedText = vscode . window . activeTextEditor . document . getText ( vscode . window . activeTextEditor . selection ) ;
68+ console . log ( `[smartSend.smoke] Selected entire file (${ selectedText . split ( '\\n' ) . length } lines, ${ selectedText . length } chars)` ) ;
6569
6670 // Wait a bit for the editor state to settle
6771 console . log ( `[smartSend.smoke] Waiting 500ms for editor state to settle...` ) ;
@@ -71,26 +75,38 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
7175 const terminalsBefore = vscode . window . terminals . length ;
7276 console . log ( `[smartSend.smoke] Number of terminals before execution: ${ terminalsBefore } ` ) ;
7377
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+ // Verify the active editor is correct before executing command
79+ if ( vscode . window . activeTextEditor ) {
80+ console . log ( `[smartSend.smoke] Active editor before command: ${ vscode . window . activeTextEditor . document . uri . fsPath } ` ) ;
81+ console . log ( `[smartSend.smoke] Active editor language: ${ vscode . window . activeTextEditor . document . languageId } ` ) ;
82+ } else {
83+ console . error ( `[smartSend.smoke] ERROR: No active text editor before command!` ) ;
7884 }
7985
8086 const startTime = Date . now ( ) ;
8187 console . log (
8288 `[smartSend.smoke] Executing first 'python.execSelectionInTerminal' command at ${ new Date ( ) . toISOString ( ) } ` ,
8389 ) ;
90+ console . log ( `[smartSend.smoke] NOTE: Passing no arguments to allow smart selection to work on active editor` ) ;
8491
85- await vscode . commands
86- . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
87- . then ( undefined , ( err ) => {
88- console . error ( `[smartSend.smoke] First command failed: ${ err } ` ) ;
89- assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
90- } ) ;
92+ await vscode . commands . executeCommand < void > ( 'python.execSelectionInTerminal' ) . then ( undefined , ( err ) => {
93+ console . error ( `[smartSend.smoke] First command failed: ${ err } ` ) ;
94+ assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
95+ } ) ;
9196 const firstCmdTime = Date . now ( ) ;
9297 console . log ( `[smartSend.smoke] First command completed in ${ firstCmdTime - startTime } ms` ) ;
9398
99+ // Check if smart selection changed the selection
100+ if ( vscode . window . activeTextEditor ) {
101+ const selectionAfterCmd = vscode . window . activeTextEditor . selection ;
102+ const selectedText = vscode . window . activeTextEditor . document . getText ( selectionAfterCmd ) ;
103+ console . log ( `[smartSend.smoke] Selection after command - start: (${ selectionAfterCmd . start . line } , ${ selectionAfterCmd . start . character } ), end: (${ selectionAfterCmd . end . line } , ${ selectionAfterCmd . end . character } )` ) ;
104+ console . log ( `[smartSend.smoke] Selected text after command (first 100 chars): "${ selectedText . substring ( 0 , 100 ) . replace ( / \n / g, '\\n' ) } "` ) ;
105+ console . log ( `[smartSend.smoke] Active editor document URI: ${ vscode . window . activeTextEditor . document . uri . fsPath } ` ) ;
106+ } else {
107+ console . error ( `[smartSend.smoke] WARNING: No active text editor after command execution!` ) ;
108+ }
109+
94110 const terminalsAfter = vscode . window . terminals . length ;
95111 console . log ( `[smartSend.smoke] Number of terminals after first execution: ${ terminalsAfter } ` ) ;
96112 if ( vscode . window . activeTerminal ) {
@@ -133,6 +149,13 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
133149 console . error ( `[smartSend.smoke] Output file exists: ${ await fs . pathExists ( outputFile ) } ` ) ;
134150 console . error ( `[smartSend.smoke] Number of terminals: ${ vscode . window . terminals . length } ` ) ;
135151
152+ // Check final editor state
153+ if ( vscode . window . activeTextEditor ) {
154+ console . error ( `[smartSend.smoke] Final active editor: ${ vscode . window . activeTextEditor . document . uri . fsPath } ` ) ;
155+ const finalSelection = vscode . window . activeTextEditor . selection ;
156+ console . error ( `[smartSend.smoke] Final selection - start: (${ finalSelection . start . line } , ${ finalSelection . start . character } ), end: (${ finalSelection . end . line } , ${ finalSelection . end . character } )` ) ;
157+ }
158+
136159 // List directory contents
137160 const dir = path . dirname ( outputFile ) ;
138161 try {
@@ -147,21 +170,17 @@ suite('Smoke Test: Run Smart Selection and Advance Cursor', async () => {
147170 }
148171
149172 console . log ( `[smartSend.smoke] Executing second 'python.execSelectionInTerminal' command` ) ;
150- await vscode . commands
151- . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
152- . then ( undefined , ( err ) => {
153- console . error ( `[smartSend.smoke] Second command failed: ${ err } ` ) ;
154- assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
155- } ) ;
173+ await vscode . commands . executeCommand < void > ( 'python.execSelectionInTerminal' ) . then ( undefined , ( err ) => {
174+ console . error ( `[smartSend.smoke] Second command failed: ${ err } ` ) ;
175+ assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
176+ } ) ;
156177 console . log ( `[smartSend.smoke] Second command completed` ) ;
157178
158179 console . log ( `[smartSend.smoke] Executing third 'python.execSelectionInTerminal' command` ) ;
159- await vscode . commands
160- . executeCommand < void > ( 'python.execSelectionInTerminal' , textDocument . uri )
161- . then ( undefined , ( err ) => {
162- console . error ( `[smartSend.smoke] Third command failed: ${ err } ` ) ;
163- assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
164- } ) ;
180+ await vscode . commands . executeCommand < void > ( 'python.execSelectionInTerminal' ) . then ( undefined , ( err ) => {
181+ console . error ( `[smartSend.smoke] Third command failed: ${ err } ` ) ;
182+ assert . fail ( `Something went wrong running the Python file in the terminal: ${ err } ` ) ;
183+ } ) ;
165184 console . log ( `[smartSend.smoke] Third command completed` ) ;
166185
167186 async function wait ( ) {
0 commit comments