5
5
6
6
import { inject , injectable } from 'inversify' ;
7
7
import { Disposable , EventEmitter , Terminal , Uri } from 'vscode' ;
8
-
8
+ import * as path from 'path' ;
9
9
import { ICommandManager , IDocumentManager } from '../../common/application/types' ;
10
10
import { Commands } from '../../common/constants' ;
11
11
import '../../common/extensions' ;
@@ -130,6 +130,15 @@ export class CodeExecutionManager implements ICodeExecutionManager {
130
130
if ( ! fileToExecute ) {
131
131
return ;
132
132
}
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
+
133
142
const fileAfterSave = await codeExecutionHelper . saveFileIfDirty ( fileToExecute ) ;
134
143
if ( fileAfterSave ) {
135
144
fileToExecute = fileAfterSave ;
@@ -138,19 +147,9 @@ export class CodeExecutionManager implements ICodeExecutionManager {
138
147
const show = this . shouldTerminalFocusOnStart ( fileToExecute ) ;
139
148
let terminal : Terminal | undefined ;
140
149
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 ) ;
147
151
} else {
148
- terminal = await runInTerminal (
149
- fileToExecute ,
150
- [ fileToExecute . fsPath . fileToCommandArgumentForPythonExt ( ) ] ,
151
- undefined ,
152
- show ,
153
- ) ;
152
+ terminal = await runInTerminal ( fileToExecute , totalArgs , cwd , show ) ;
154
153
}
155
154
156
155
if ( terminal ) {
0 commit comments