11import { commands , extensions , window , ProgressLocation } from "vscode" ;
22import Logger , { LoggerSource } from "../logger.mjs" ;
33
4-
54export async function cmakeToolsForcePicoKit ( ) : Promise < void > {
65 // Check if the CMake Tools extension is installed and active
76 let foundCmakeToolsExtension = false ;
87 for ( let i = 0 ; i < 2 ; i ++ ) {
9- const cmakeToolsExtension =
10- extensions . getExtension ( "ms-vscode.cmake-tools" ) ;
8+ const cmakeToolsExtension = extensions . getExtension (
9+ "ms-vscode.cmake-tools"
10+ ) ;
1111 if ( cmakeToolsExtension !== undefined ) {
1212 Logger . debug (
1313 LoggerSource . cmake ,
@@ -21,11 +21,11 @@ export async function cmakeToolsForcePicoKit(): Promise<void> {
2121
2222 // Attempt to activate the extension
2323 const onActivate = cmakeToolsExtension . activate ( ) ;
24- const onTimeout = new Promise < string > ( ( resolve ) => {
24+ const onTimeout = new Promise < string > ( resolve => {
2525 setTimeout ( resolve , 2000 , "timeout" ) ;
2626 } ) ;
2727
28- await Promise . race ( [ onActivate , onTimeout ] ) . then ( ( value ) => {
28+ await Promise . race ( [ onActivate , onTimeout ] ) . then ( value => {
2929 if ( value === "timeout" ) {
3030 Logger . warn (
3131 LoggerSource . cmake ,
@@ -38,65 +38,58 @@ export async function cmakeToolsForcePicoKit(): Promise<void> {
3838 } ) ;
3939 } else {
4040 // Undefined if not installed/disabled
41- Logger . debug (
42- LoggerSource . cmake ,
43- `cmakeToolsExtension: undefined`
44- ) ;
41+ Logger . debug ( LoggerSource . cmake , `cmakeToolsExtension: undefined` ) ;
4542 break ;
4643 }
4744 await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
4845 }
4946
5047 if ( ! foundCmakeToolsExtension ) {
5148 // Give up and return, as this function is non-essential
52- Logger . warn (
53- LoggerSource . cmake ,
54- "cmakeToolsExtension not available yet"
55- ) ;
49+ Logger . warn ( LoggerSource . cmake , "cmakeToolsExtension not available yet" ) ;
5650
5751 return ;
5852 }
5953
60- let cmakeToolsKit = await commands . executeCommand (
61- "cmake.buildKit"
62- ) ;
54+ let cmakeToolsKit = await commands . executeCommand ( "cmake.buildKit" ) ;
6355 if ( cmakeToolsKit === "Pico" ) {
6456 return ;
6557 }
6658
67- await window . withProgress ( {
68- location : ProgressLocation . Notification ,
69- title : "Select the Pico kit in the dialog at the top of the window" ,
70- cancellable : false ,
71- } , async progress => {
72- let i = 0 ;
73- while ( cmakeToolsKit !== "Pico" ) {
74- if ( i >= 2 ) {
75- const result = await window . showErrorMessage (
76- "You did not select the Pico kit - " +
77- "you must select the Pico kit in the dialog, " +
78- "else this extension will not work" ,
79- "Try again" ,
80- "Cancel"
81- ) ;
59+ await window . withProgress (
60+ {
61+ location : ProgressLocation . Notification ,
62+ title : "Select the Pico kit in the dialog at the top of the window" ,
63+ cancellable : false ,
64+ } ,
65+ async progress => {
66+ let i = 0 ;
67+ while ( cmakeToolsKit !== "Pico" ) {
68+ if ( i >= 2 ) {
69+ const result = await window . showErrorMessage (
70+ "You did not select the Pico kit - " +
71+ "you must select the Pico kit in the dialog, " +
72+ "else this extension will not work" ,
73+ "Try again" ,
74+ "Cancel"
75+ ) ;
8276
83- if ( result === "Try again" ) {
84- i = 0 ;
85- continue ;
86- }
77+ if ( result === "Try again" ) {
78+ i = 0 ;
79+ continue ;
80+ }
8781
88- progress . report ( { increment : 100 } ) ;
82+ progress . report ( { increment : 100 } ) ;
8983
90- return ;
84+ return ;
85+ }
86+ await commands . executeCommand ( "cmake.selectKit" ) ;
87+ cmakeToolsKit = await commands . executeCommand ( "cmake.buildKit" ) ;
88+ i ++ ;
9189 }
92- await commands . executeCommand ( "cmake.selectKit" ) ;
93- cmakeToolsKit = await commands . executeCommand (
94- "cmake.buildKit"
95- ) ;
96- i ++ ;
97- }
98- progress . report ( { increment : 100 } ) ;
90+ progress . report ( { increment : 100 } ) ;
9991
100- return ;
101- } ) ;
92+ return ;
93+ }
94+ ) ;
10295}
0 commit comments