@@ -17,6 +17,7 @@ const OUTPUT_CHANNEL = vscode.window.createOutputChannel(OUTPUT_CHANNEL_NAME);
17
17
var extensionContext : vscode . ExtensionContext | undefined = undefined ;
18
18
var pythonLanguageServerMain : string | undefined ;
19
19
var pythonDebugAdapterMain : string | undefined ;
20
+ //var pythonDebugpyPath: string | undefined;
20
21
21
22
function getPythonCommand ( folder : vscode . WorkspaceFolder | undefined ) : string | undefined {
22
23
let config = vscode . workspace . getConfiguration ( CONFIG_SECTION , folder ) ;
@@ -28,7 +29,7 @@ function getPythonCommand(folder: vscode.WorkspaceFolder | undefined): string |
28
29
result = configPython ;
29
30
} else {
30
31
const pythonExtension = vscode . extensions . getExtension ( "ms-python.python" ) ! ;
31
- let pythonExtensionPythonPath : string [ ] | undefined = pythonExtension . exports . settings . getExecutionDetails (
32
+ let pythonExtensionPythonPath : string [ ] | undefined = pythonExtension ? .exports ? .settings ? .getExecutionDetails (
32
33
folder ?. uri
33
34
) ?. execCommand ;
34
35
@@ -44,16 +45,6 @@ let clientsMutex = new Mutex();
44
45
let clients : Map < string , LanguageClient > = new Map ( ) ;
45
46
46
47
async function updateLoadedDocumentClients ( uri ?: vscode . Uri | undefined ) {
47
- // if (uri && clients.has(uri.toString())) {
48
- // await clientsMutex.dispatch(async () => {
49
- // let client = clients.get(uri.toString());
50
- // clients.delete(uri.toString());
51
- // await client?.stop();
52
- // });
53
-
54
- // await getLanguageClientForResource(uri);
55
- // }
56
-
57
48
OUTPUT_CHANNEL . appendLine ( "initialze/restart all needed language clients." ) ;
58
49
await clientsMutex . dispatch ( async ( ) => {
59
50
for ( let client of clients . values ( ) ) {
@@ -113,7 +104,7 @@ async function getLanguageClientForDocument(document: vscode.TextDocument): Prom
113
104
}
114
105
115
106
async function getLanguageClientForResource ( resource : string | vscode . Uri ) : Promise < LanguageClient | undefined > {
116
- var client = await clientsMutex . dispatch ( async ( ) => {
107
+ return await clientsMutex . dispatch ( async ( ) => {
117
108
let uri = resource instanceof vscode . Uri ? resource : vscode . Uri . parse ( resource ) ;
118
109
let workspaceFolder = vscode . workspace . getWorkspaceFolder ( uri ) ;
119
110
@@ -142,7 +133,7 @@ async function getLanguageClientForResource(resource: string | vscode.Uri): Prom
142
133
{ scheme : "file" , language : "robotframework" , pattern : `${ workspaceFolder . uri . fsPath } /**/*` } ,
143
134
] ,
144
135
synchronize : {
145
- configurationSection : [ CONFIG_SECTION , "python" ] ,
136
+ configurationSection : [ CONFIG_SECTION ] ,
146
137
} ,
147
138
initializationOptions : {
148
139
storageUri : extensionContext ?. storageUri ?. toString ( ) ,
@@ -167,13 +158,22 @@ async function getLanguageClientForResource(resource: string | vscode.Uri): Prom
167
158
result . start ( ) ;
168
159
169
160
result = await result . onReady ( ) . then (
170
- ( _ ) => {
171
- OUTPUT_CHANNEL . appendLine ( `client ${ client ?. clientOptions . workspaceFolder ?. uri ?? "unknown" } ready.` ) ;
161
+ async ( _ ) => {
162
+ OUTPUT_CHANNEL . appendLine ( `client ${ result ?. clientOptions . workspaceFolder ?. uri ?? "unknown" } ready.` ) ;
163
+ var counter = 0 ;
164
+ try {
165
+ while ( ! result ?. initializeResult && counter < 1000 ) {
166
+ await sleep ( 10 ) ;
167
+ counter ++ ;
168
+ }
169
+ } catch {
170
+ return undefined ;
171
+ }
172
172
return result ;
173
173
} ,
174
- ( reason ) => {
174
+ async ( reason ) => {
175
175
OUTPUT_CHANNEL . appendLine (
176
- `client ${ client ?. clientOptions . workspaceFolder ?. uri ?? "unknown" } error: ${ reason } `
176
+ `client ${ result ?. clientOptions . workspaceFolder ?. uri ?? "unknown" } error: ${ reason } `
177
177
) ;
178
178
vscode . window . showErrorMessage ( reason . message ?? "Unknown error." ) ;
179
179
return undefined ;
@@ -184,22 +184,6 @@ async function getLanguageClientForResource(resource: string | vscode.Uri): Prom
184
184
185
185
return result ;
186
186
} ) ;
187
-
188
- if ( client ) {
189
- // be sure client is correctly initialized
190
-
191
- var counter = 0 ;
192
- try {
193
- while ( ! client . initializeResult && counter < 1000 ) {
194
- await sleep ( 10 ) ;
195
- counter ++ ;
196
- }
197
- } catch {
198
- return undefined ;
199
- }
200
- }
201
-
202
- return client ;
203
187
}
204
188
205
189
function getServerOptionsTCP ( folder : vscode . WorkspaceFolder ) {
@@ -287,6 +271,10 @@ class RobotCodeDebugConfigurationProvider implements vscode.DebugConfigurationPr
287
271
288
272
debugConfiguration . env = { ...config . get < Object > ( "robot.env" , { } ) , ...( debugConfiguration . env ?? { } ) } ;
289
273
274
+ // if (pythonDebugpyPath) {
275
+ // debugConfiguration.env = { PYTHONPATH: path.dirname(pythonDebugpyPath), ...debugConfiguration.env };
276
+ // }
277
+
290
278
if ( ! debugConfiguration . attachPython || debugConfiguration . noDebug ) {
291
279
debugConfiguration . attachPython = false ;
292
280
}
@@ -530,6 +518,8 @@ export async function activateAsync(context: vscode.ExtensionContext) {
530
518
531
519
await pythonExtension . activate ( ) ;
532
520
521
+ //pythonDebugpyPath = await pythonExtension?.exports?.debug?.getDebuggerPackagePath();
522
+
533
523
OUTPUT_CHANNEL . appendLine ( "Python Extension is active" ) ;
534
524
535
525
context . subscriptions . push (
0 commit comments