55
66import { inject , injectable } from 'inversify' ;
77import { Disposable , EventEmitter , Terminal , Uri } from 'vscode' ;
8-
8+ import * as path from 'path' ;
99import { ICommandManager , IDocumentManager } from '../../common/application/types' ;
1010import { Commands } from '../../common/constants' ;
1111import '../../common/extensions' ;
@@ -130,6 +130,15 @@ export class CodeExecutionManager implements ICodeExecutionManager {
130130 if ( ! fileToExecute ) {
131131 return ;
132132 }
133+
134+ // Check on setting terminal.executeInFileDir
135+ const pythonSettings = this . configSettings . getSettings ( file ) ;
136+ let cwd = pythonSettings . terminal . executeInFileDir ? path . dirname ( fileToExecute . fsPath ) : undefined ;
137+
138+ // Check on setting terminal.launchArgs
139+ const launchArgs = pythonSettings . terminal . launchArgs ;
140+ const totalArgs = [ ...launchArgs , fileToExecute . fsPath . fileToCommandArgumentForPythonExt ( ) ] ;
141+
133142 const fileAfterSave = await codeExecutionHelper . saveFileIfDirty ( fileToExecute ) ;
134143 if ( fileAfterSave ) {
135144 fileToExecute = fileAfterSave ;
@@ -138,19 +147,9 @@ export class CodeExecutionManager implements ICodeExecutionManager {
138147 const show = this . shouldTerminalFocusOnStart ( fileToExecute ) ;
139148 let terminal : Terminal | undefined ;
140149 if ( dedicated ) {
141- terminal = await runInDedicatedTerminal (
142- fileToExecute ,
143- [ fileToExecute . fsPath . fileToCommandArgumentForPythonExt ( ) ] ,
144- undefined ,
145- show ,
146- ) ;
150+ terminal = await runInDedicatedTerminal ( fileToExecute , totalArgs , cwd , show ) ;
147151 } else {
148- terminal = await runInTerminal (
149- fileToExecute ,
150- [ fileToExecute . fsPath . fileToCommandArgumentForPythonExt ( ) ] ,
151- undefined ,
152- show ,
153- ) ;
152+ terminal = await runInTerminal ( fileToExecute , totalArgs , cwd , show ) ;
154153 }
155154
156155 if ( terminal ) {
0 commit comments