@@ -12,11 +12,12 @@ import * as config from './config';
1212// Returns the clangd path to be used, or null if clangd is not installed.
1313export async function activate (
1414 context : ClangdContext , globalStoragePath : string ,
15- workspaceState : vscode . Memento ) : Promise < string | null > {
15+ workspaceState : vscode . Memento ,
16+ globalState : vscode . Memento ) : Promise < string | null > {
1617 // If the workspace overrides clangd.path, give the user a chance to bless it.
1718 await config . getSecureOrPrompt < string > ( 'path' , workspaceState ) ;
1819
19- const ui = new UI ( context , globalStoragePath , workspaceState ) ;
20+ const ui = new UI ( context , globalStoragePath , workspaceState , globalState ) ;
2021 context . subscriptions . push ( vscode . commands . registerCommand (
2122 'clangd.install' , async ( ) => common . installLatest ( ui ) ) ) ;
2223 context . subscriptions . push ( vscode . commands . registerCommand (
@@ -27,7 +28,8 @@ export async function activate(
2728
2829class UI {
2930 constructor ( private context : ClangdContext , private globalStoragePath : string ,
30- private workspaceState : vscode . Memento ) { }
31+ private workspaceState : vscode . Memento ,
32+ private globalState : vscode . Memento ) { }
3133
3234 get storagePath ( ) : string { return this . globalStoragePath ; }
3335 async choose ( prompt : string , options : string [ ] ) : Promise < string | undefined > {
@@ -86,6 +88,21 @@ class UI {
8688 }
8789 }
8890
91+ async promptDelete ( path : string ) : Promise < boolean | undefined > {
92+ const message = `Delete the previous clangd installation? ${ path } ` ;
93+ const remove = 'Delete it' ;
94+ const preserve = 'Keep it' ;
95+ const response =
96+ await vscode . window . showInformationMessage ( message , remove , preserve ) ;
97+ if ( response === remove ) {
98+ return true ;
99+ } else if ( response === preserve ) {
100+ return false ;
101+ } else {
102+ return undefined ; // User dismissed prompt, bail out.
103+ }
104+ }
105+
89106 async promptReload ( message : string ) {
90107 if ( await vscode . window . showInformationMessage ( message , 'Reload window' ) )
91108 vscode . commands . executeCommand ( 'workbench.action.reloadWindow' ) ;
@@ -136,4 +153,11 @@ class UI {
136153 set clangdPath ( p : string ) {
137154 config . update ( 'path' , p , vscode . ConfigurationTarget . Global ) ;
138155 }
156+
157+ get cleanupPath ( ) : string | undefined {
158+ return this . globalState . get < string > ( 'clangd.install.cleanupPath' ) ;
159+ }
160+ set cleanupPath ( p : string | undefined ) {
161+ this . globalState . update ( 'clangd.install.cleanupPath' , p ) ;
162+ }
139163}
0 commit comments