File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
DocumentSelector ,
19
19
LSPAny ,
20
20
ExecuteCommandRequest ,
21
+ TransportKind ,
21
22
} from 'vscode-languageclient/node' ;
22
23
23
24
export let defaultClient : LuaClient | null ;
@@ -106,8 +107,14 @@ class LuaClient {
106
107
107
108
if ( ! Array . isArray ( commandParam ) ) throw new Error ( "Lua.misc.parameters must be an Array!" ) ;
108
109
110
+ const port = this . getPort ( commandParam ) ;
111
+
109
112
const serverOptions : ServerOptions = {
110
113
command : command ,
114
+ transport : port ? {
115
+ kind : TransportKind . socket ,
116
+ port : port ,
117
+ } : undefined ,
111
118
args : commandParam ,
112
119
} ;
113
120
@@ -177,6 +184,23 @@ class LuaClient {
177
184
return command ;
178
185
}
179
186
187
+ // Generated by Copilot
188
+ private getPort ( commandParam : string [ ] ) : number | undefined {
189
+ // "--socket=xxxx" or "--socket xxxx"
190
+ const portIndex = commandParam . findIndex ( ( value ) => {
191
+ return value . startsWith ( "--socket" ) ;
192
+ } ) ;
193
+ if ( portIndex === - 1 ) {
194
+ return undefined ;
195
+ } ;
196
+ const port = commandParam [ portIndex ] . split ( "=" ) [ 1 ]
197
+ || commandParam [ portIndex + 1 ] ;
198
+ if ( ! port ) {
199
+ return undefined ;
200
+ } ;
201
+ return Number ( port ) ;
202
+ }
203
+
180
204
async stop ( ) {
181
205
this . client . stop ( ) ;
182
206
for ( const disposable of this . disposables ) {
You can’t perform that action at this time.
0 commit comments