@@ -81,8 +81,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
8181 : this . sessionManager . getSessionDetails ( ) ;
8282
8383 if ( sessionDetails === undefined ) {
84- // eslint-disable-next-line @typescript-eslint/no-floating-promises
85- this . logger . writeAndShowError ( `No session details available for ${ session . name } ` ) ;
84+ void this . logger . writeAndShowError ( `PowerShell session details not available for ${ session . name } ` ) ;
8685 return ;
8786 }
8887
@@ -103,17 +102,15 @@ export class DebugSessionFeature extends LanguageClientConsumer
103102 languageClient . onNotification (
104103 StartDebuggerNotificationType ,
105104 // TODO: Use a named debug configuration.
106- // eslint-disable-next-line @typescript-eslint/no-misused-promises
107- ( ) => vscode . debug . startDebugging ( undefined , {
105+ ( ) => void vscode . debug . startDebugging ( undefined , {
108106 request : "launch" ,
109107 type : "PowerShell" ,
110108 name : "PowerShell: Interactive Session"
111109 } ) ) ,
112110
113111 languageClient . onNotification (
114112 StopDebuggerNotificationType ,
115- // eslint-disable-next-line @typescript-eslint/no-misused-promises
116- ( ) => vscode . debug . stopDebugging ( undefined ) )
113+ ( ) => void vscode . debug . stopDebugging ( undefined ) )
117114 ] ;
118115 }
119116
@@ -192,7 +189,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
192189
193190 if ( config . script === "${file}" || config . script === "${relativeFile}" ) {
194191 if ( vscode . window . activeTextEditor === undefined ) {
195- await vscode . window . showErrorMessage ( "To debug the 'Current File', you must first open a PowerShell script file in the editor." ) ;
192+ void this . logger . writeAndShowError ( "To debug the 'Current File', you must first open a PowerShell script file in the editor." ) ;
196193 return undefined ;
197194 }
198195 config . current_document = true ;
@@ -218,7 +215,7 @@ export class DebugSessionFeature extends LanguageClientConsumer
218215 } else if ( config . request === "launch" ) {
219216 resolvedConfig = await this . resolveLaunchDebugConfiguration ( config ) ;
220217 } else {
221- await vscode . window . showErrorMessage ( `The request type was invalid: '${ config . request } '`) ;
218+ void this . logger . writeAndShowError ( `PowerShell debug configuration's request type was invalid: '${ config . request } '. `) ;
222219 return null ;
223220 }
224221
@@ -235,48 +232,45 @@ export class DebugSessionFeature extends LanguageClientConsumer
235232 }
236233
237234 private async resolveLaunchDebugConfiguration ( config : DebugConfiguration ) : Promise < DebugConfiguration | undefined > {
238- // Check the languageId only for current documents (which includes untitled documents).
235+ // Check the languageId and file extension only for current documents
236+ // (which includes untitled documents). This prevents accidentally
237+ // running the debugger for an open non-PowerShell file.
239238 if ( config . current_document ) {
240239 const currentDocument = vscode . window . activeTextEditor ?. document ;
241240 if ( currentDocument ?. languageId !== "powershell" ) {
242- await vscode . window . showErrorMessage ( "Please change the current document's language mode to PowerShell." ) ;
241+ void this . logger . writeAndShowError ( `PowerShell does not support debugging this language mode: ' ${ currentDocument ?. languageId } '.` ) ;
243242 return undefined ;
244243 }
245- }
246244
247- // Check the temporary console setting for untitled documents only, and
248- // check the document extension for if the script is an extant file (it
249- // could be inline).
250- if ( config . untitled_document ) {
251- if ( config . createTemporaryIntegratedConsole ) {
252- await vscode . window . showErrorMessage ( "Debugging untitled files in a temporary console is not supported." ) ;
253- return undefined ;
254- }
255- } else if ( config . script ) {
256- // TODO: Why even bother with this complexity?
257245 if ( await utils . checkIfFileExists ( config . script ) ) {
258246 const ext = path . extname ( config . script ) . toLowerCase ( ) ;
259247 if ( ! ( ext === ".ps1" || ext === ".psm1" ) ) {
260- await vscode . window . showErrorMessage ( `PowerShell does not support debugging this file type: '${ path . basename ( config . script ) } '` ) ;
248+ void this . logger . writeAndShowError ( `PowerShell does not support debugging this file type: '${ path . basename ( config . script ) } '. ` ) ;
261249 return undefined ;
262250 }
263251 }
264252 }
265253
254+ // Check the temporary console setting for untitled documents only.
255+ if ( config . untitled_document && config . createTemporaryIntegratedConsole ) {
256+ void this . logger . writeAndShowError ( "PowerShell does not support debugging untitled files in a temporary console." ) ;
257+ return undefined ;
258+ }
259+
266260 return config ;
267261 }
268262
269263 private async resolveAttachDebugConfiguration ( config : DebugConfiguration ) : Promise < DebugConfiguration | undefined | null > {
270264 const platformDetails = getPlatformDetails ( ) ;
271265 const versionDetails = this . sessionManager . getPowerShellVersionDetails ( ) ;
272266 if ( versionDetails === undefined ) {
273- await vscode . window . showErrorMessage ( `Session version details were not found for ${ config . name } `) ;
267+ void this . logger . writeAndShowError ( `PowerShell session version details were not found for ' ${ config . name } '. `) ;
274268 return null ;
275269 }
276270
277271 // Cross-platform attach to process was added in 6.2.0-preview.4.
278272 if ( versionDetails . version < "7.0.0" && platformDetails . operatingSystem !== OperatingSystem . Windows ) {
279- await vscode . window . showErrorMessage ( `Attaching to a PowerShell Host Process on ${ OperatingSystem [ platformDetails . operatingSystem ] } requires PowerShell 7.0 or higher.` ) ;
273+ void this . logger . writeAndShowError ( `Attaching to a PowerShell Host Process on ${ OperatingSystem [ platformDetails . operatingSystem ] } requires PowerShell 7.0 or higher.` ) ;
280274 return undefined ;
281275 }
282276
@@ -309,10 +303,9 @@ export class SpecifyScriptArgsFeature implements vscode.Disposable {
309303 constructor ( context : vscode . ExtensionContext ) {
310304 this . context = context ;
311305
312- this . command =
313- vscode . commands . registerCommand ( "PowerShell.SpecifyScriptArgs" , ( ) => {
314- return this . specifyScriptArguments ( ) ;
315- } ) ;
306+ this . command = vscode . commands . registerCommand ( "PowerShell.SpecifyScriptArgs" , ( ) => {
307+ return this . specifyScriptArguments ( ) ;
308+ } ) ;
316309 }
317310
318311 public dispose ( ) {
@@ -366,7 +359,7 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
366359 private waitingForClientToken ?: vscode . CancellationTokenSource ;
367360 private getLanguageClientResolve ?: ( value : LanguageClient ) => void ;
368361
369- constructor ( ) {
362+ constructor ( private logger : Logger ) {
370363 super ( ) ;
371364
372365 this . command =
@@ -401,7 +394,6 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
401394 ( resolve , reject ) => {
402395 this . getLanguageClientResolve = resolve ;
403396
404- // eslint-disable-next-line @typescript-eslint/no-floating-promises
405397 vscode . window
406398 . showQuickPick (
407399 [ "Cancel" ] ,
@@ -412,17 +404,15 @@ export class PickPSHostProcessFeature extends LanguageClientConsumer {
412404 this . clearWaitingToken ( ) ;
413405 reject ( ) ;
414406 }
415- } ) ;
407+ } , undefined ) ;
416408
417409 // Cancel the loading prompt after 60 seconds
418410 setTimeout ( ( ) => {
419411 if ( this . waitingForClientToken ) {
420412 this . clearWaitingToken ( ) ;
421413 reject ( ) ;
422414
423- // eslint-disable-next-line @typescript-eslint/no-floating-promises
424- vscode . window . showErrorMessage (
425- "Attach to PowerShell host process: PowerShell session took too long to start." ) ;
415+ void this . logger . writeAndShowError ( "Attach to PowerShell host process: PowerShell session took too long to start." ) ;
426416 }
427417 } , 60000 ) ;
428418 } ,
@@ -495,7 +485,7 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
495485 private waitingForClientToken ?: vscode . CancellationTokenSource ;
496486 private getLanguageClientResolve ?: ( value : LanguageClient ) => void ;
497487
498- constructor ( ) {
488+ constructor ( private logger : Logger ) {
499489 super ( ) ;
500490 this . command =
501491 vscode . commands . registerCommand ( "PowerShell.PickRunspace" , ( processId ) => {
@@ -529,7 +519,6 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
529519 ( resolve , reject ) => {
530520 this . getLanguageClientResolve = resolve ;
531521
532- // eslint-disable-next-line @typescript-eslint/no-floating-promises
533522 vscode . window
534523 . showQuickPick (
535524 [ "Cancel" ] ,
@@ -540,17 +529,15 @@ export class PickRunspaceFeature extends LanguageClientConsumer {
540529 this . clearWaitingToken ( ) ;
541530 reject ( ) ;
542531 }
543- } ) ;
532+ } , undefined ) ;
544533
545534 // Cancel the loading prompt after 60 seconds
546535 setTimeout ( ( ) => {
547536 if ( this . waitingForClientToken ) {
548537 this . clearWaitingToken ( ) ;
549538 reject ( ) ;
550539
551- // eslint-disable-next-line @typescript-eslint/no-floating-promises
552- vscode . window . showErrorMessage (
553- "Attach to PowerShell host process: PowerShell session took too long to start." ) ;
540+ void this . logger . writeAndShowError ( "Attach to PowerShell host process: PowerShell session took too long to start." ) ;
554541 }
555542 } , 60000 ) ;
556543 } ,
0 commit comments