@@ -106,25 +106,26 @@ export interface JupyterSettings {
106106
107107const IS_TEST_EXECUTION = process . env [ 'PYTHON_DONJAYAMANNE_TEST' ] === '1' ;
108108
109- const systemVariables : SystemVariables = new SystemVariables ( ) ;
110109export class PythonSettings extends EventEmitter implements IPythonSettings {
111110 private static pythonSettings : PythonSettings = new PythonSettings ( ) ;
111+ private disposables : vscode . Disposable [ ] = [ ] ;
112112 constructor ( ) {
113113 super ( ) ;
114114 if ( PythonSettings . pythonSettings ) {
115115 throw new Error ( 'Singleton class, Use getInstance method' ) ;
116116 }
117- vscode . workspace . onDidChangeConfiguration ( ( ) => {
117+ this . disposables . push ( vscode . workspace . onDidChangeConfiguration ( ( ) => {
118118 this . initializeSettings ( ) ;
119- } ) ;
120-
119+ } ) ) ;
120+
121121 this . initializeSettings ( ) ;
122122 }
123123 public static getInstance ( ) : PythonSettings {
124124 return PythonSettings . pythonSettings ;
125125 }
126126 private initializeSettings ( ) {
127- const workspaceRoot = IS_TEST_EXECUTION ? __dirname : vscode . workspace . rootPath ;
127+ const systemVariables : SystemVariables = new SystemVariables ( ) ;
128+ const workspaceRoot = ( IS_TEST_EXECUTION || typeof vscode . workspace . rootPath !== 'string' ) ? __dirname : vscode . workspace . rootPath ;
128129 let pythonSettings = vscode . workspace . getConfiguration ( 'python' ) ;
129130 this . pythonPath = systemVariables . resolveAny ( pythonSettings . get < string > ( 'pythonPath' ) ) ;
130131 this . pythonPath = getAbsolutePath ( this . pythonPath , IS_TEST_EXECUTION ? __dirname : workspaceRoot ) ;
@@ -225,7 +226,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
225226 exclusionPatterns : [ ] ,
226227 rebuildOnFileSave : true ,
227228 rebuildOnStart : true ,
228- tagFilePath : path . join ( vscode . workspace . rootPath , "tags" )
229+ tagFilePath : path . join ( workspaceRoot , "tags" )
229230 } ;
230231
231232 let unitTestSettings = systemVariables . resolveAny ( pythonSettings . get < IUnitTestSettings > ( 'unitTest' ) ) ;
@@ -238,7 +239,6 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
238239 this . unitTest = { nosetestArgs : [ ] , pyTestArgs : [ ] , unittestArgs : [ ] } as IUnitTestSettings ;
239240 }
240241 }
241- this . emit ( 'change' ) ;
242242
243243 // Support for travis
244244 this . unitTest = this . unitTest ? this . unitTest : {
@@ -278,6 +278,8 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
278278 this . jupyter = this . jupyter ? this . jupyter : {
279279 appendResults : true , defaultKernel : '' , startupCode : [ ]
280280 } ;
281+
282+ this . emit ( 'change' ) ;
281283 }
282284
283285 public pythonPath : string ;
0 commit comments