@@ -185,6 +185,7 @@ type ClojureLspCommand = {
185
185
command : string ;
186
186
extraParamFn ?: ( ) => Thenable < string > ;
187
187
category ?: string ;
188
+ requireLocalFile ?: boolean ;
188
189
} ;
189
190
190
191
function makePromptForInput ( placeHolder : string ) {
@@ -197,6 +198,19 @@ function makePromptForInput(placeHolder: string) {
197
198
} ;
198
199
}
199
200
201
+ function makeQuickPickForInput ( ) {
202
+ return async ( ) => {
203
+ const uris = await vscode . window . showOpenDialog ( {
204
+ canSelectFolders : false ,
205
+ canSelectFiles : true ,
206
+ canSelectMany : false ,
207
+ openLabel : 'Select destination' ,
208
+ title : 'Select destination' ,
209
+ } ) ;
210
+ return uris ?. length > 0 ? uris [ 0 ] . path : undefined ;
211
+ } ;
212
+ }
213
+
200
214
const clojureLspCommands : ClojureLspCommand [ ] = [
201
215
{
202
216
command : 'clean-ns' ,
@@ -255,6 +269,11 @@ const clojureLspCommands: ClojureLspCommand[] = [
255
269
command : 'extract-function' ,
256
270
extraParamFn : makePromptForInput ( 'Function name' ) ,
257
271
} ,
272
+ {
273
+ command : 'move-form' ,
274
+ extraParamFn : makeQuickPickForInput ( ) ,
275
+ requireLocalFile : true ,
276
+ } ,
258
277
] ;
259
278
260
279
function sendCommandRequest ( command : string , args : ( number | string ) [ ] ) : void {
@@ -284,9 +303,15 @@ function registerLspCommand(command: ClojureLspCommand): vscode.Disposable {
284
303
const column = editor . selection . start . character ;
285
304
const docUri = `${ document . uri . scheme } ://${ document . uri . path } ` ;
286
305
const params = [ docUri , line , column ] ;
287
- const extraParam = command . extraParamFn ? await command . extraParamFn ( ) : undefined ;
288
- if ( ! command . extraParamFn || ( command . extraParamFn && extraParam ) ) {
289
- sendCommandRequest ( command . command , extraParam ? [ ...params , extraParam ] : params ) ;
306
+ if ( command . requireLocalFile === true && document . uri . scheme !== 'file' ) {
307
+ vscode . window . showErrorMessage ( 'This function only works on local files' ) ;
308
+ } else {
309
+ let extraParam = command . extraParamFn ? await command . extraParamFn ( ) : undefined ;
310
+ if ( command . command === 'execute-lsp-command' && command . extraParamFn && extraParam ) {
311
+ sendCommandRequest ( extraParam , params ) ;
312
+ } else if ( ! command . extraParamFn || ( command . extraParamFn && extraParam ) ) {
313
+ sendCommandRequest ( command . command , extraParam ? [ ...params , extraParam ] : params ) ;
314
+ }
290
315
}
291
316
}
292
317
} ) ;
0 commit comments