File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -37,16 +37,22 @@ export namespace JavaRuntimes {
3737 if ( runtime ) {
3838 const config = vscode . workspace . getConfiguration ( 'java.configuration' ) . get ( 'runtimes' ) ;
3939 if ( Array . isArray ( config ) ) {
40- const candidates = getSupportedJreNames ( ) . filter ( name => ! config . some ( r => r . name === name ) && compatible ( runtime , name ) ) ;
40+ const candidates = getSupportedJreNames ( ) . filter ( name => compatible ( runtime , name ) ) . reverse ( ) ;
4141 if ( candidates . length > 0 ) {
4242 const name = await vscode . window . showQuickPick ( candidates , {
4343 title : 'Select Java Runtime' ,
4444 } ) ;
4545 if ( name ) {
46- config . push ( {
46+ const newConfig = {
4747 name : name ,
4848 path : directory [ 0 ] . fsPath ,
49- } ) ;
49+ } ;
50+ const index = config . findIndex ( r => r . name === name ) ;
51+ if ( index >= 0 ) {
52+ config [ index ] = newConfig ;
53+ } else {
54+ config . push ( newConfig ) ;
55+ }
5056 vscode . workspace . getConfiguration ( 'java.configuration' ) . update ( 'runtimes' , config , vscode . ConfigurationTarget . Global ) ;
5157 vscode . window . showInformationMessage ( `JDK Directory ${ directory [ 0 ] . fsPath } added` ) ;
5258 }
You can’t perform that action at this time.
0 commit comments