@@ -6,7 +6,7 @@ import { validateRExecutablePath } from '..';
66import { config , getCurrentWorkspaceFolder , getRPathConfigEntry , isMultiRoot } from '../../util' ;
77import { isVirtual , ExecutableType } from '../service' ;
88import { RExecutableService } from '../service' ;
9- import { getRenvVersion } from '../service/renv ' ;
9+ import { getRenvVersion } from '../virtual ' ;
1010
1111class ExecutableQuickPickItem implements vscode . QuickPickItem {
1212 public recommended : boolean ;
@@ -16,25 +16,31 @@ class ExecutableQuickPickItem implements vscode.QuickPickItem {
1616 public detail ?: string ;
1717 public picked ?: boolean ;
1818 public alwaysShow ?: boolean ;
19+ public active : boolean ;
1920 private _executable : ExecutableType ;
2021
21- constructor ( executable : ExecutableType , recommended : boolean ) {
22+ constructor ( executable : ExecutableType , service : RExecutableService , workspaceFolder : vscode . WorkspaceFolder , renvVersion ?: string ) {
2223 this . _executable = executable ;
2324 this . description = executable . rBin ;
25+ this . recommended = recommendPath ( executable , workspaceFolder , renvVersion ) ;
2426
2527 if ( isVirtual ( executable ) ) {
2628 this . category = 'Virtual' ;
2729 } else {
2830 this . category = 'Global' ;
2931 }
3032
31- this . recommended = recommended ;
32-
33- if ( recommended ) {
34- this . label = `$(star) ${ executable . tooltip } ` ;
33+ if ( this . recommended ) {
34+ this . label = `$(star-full) ${ executable . tooltip } ` ;
3535 } else {
3636 this . label = executable . tooltip ;
3737 }
38+
39+ if ( service . getWorkspaceExecutable ( workspaceFolder ?. uri ?. fsPath ) ?. rBin === executable . rBin ) {
40+ this . label = `$(indent) ${ this . label } ` ;
41+ this . active = true ;
42+ }
43+
3844 }
3945
4046 public get executable ( ) : ExecutableType {
@@ -44,7 +50,7 @@ class ExecutableQuickPickItem implements vscode.QuickPickItem {
4450}
4551
4652enum PathQuickPickMenu {
47- search = '$(plus ) Enter R binary path...' ,
53+ search = '$(add ) Enter R executable path...' ,
4854 configuration = '$(settings-gear) Configuration path'
4955}
5056
@@ -105,18 +111,23 @@ export class ExecutableQuickPick implements vscode.Disposable {
105111 }
106112 ] ;
107113
108- [ ...this . service . executables ] . sort ( sortExecutables ) . forEach ( ( v ) => {
109- const item = new ExecutableQuickPickItem ( v , recommendPath ( v , this . currentFolder , renvVersion ) ) ;
110- if ( item . recommended ) {
111- recommendedItems . push ( item ) ;
114+ [ ...this . service . executables ] . sort ( sortExecutables ) . forEach ( ( executable ) => {
115+ const quickPickItem = new ExecutableQuickPickItem (
116+ executable ,
117+ this . service ,
118+ this . currentFolder ,
119+ renvVersion
120+ ) ;
121+ if ( quickPickItem . recommended ) {
122+ recommendedItems . push ( quickPickItem ) ;
112123 } else {
113- switch ( item . category ) {
124+ switch ( quickPickItem . category ) {
114125 case 'Virtual' : {
115- virtualItems . push ( item ) ;
126+ virtualItems . push ( quickPickItem ) ;
116127 break ;
117128 }
118129 case 'Global' : {
119- globalItems . push ( item ) ;
130+ globalItems . push ( quickPickItem ) ;
120131 break ;
121132 }
122133 }
@@ -125,9 +136,9 @@ export class ExecutableQuickPick implements vscode.Disposable {
125136
126137
127138 this . quickpick . items = [ ...qpItems , ...recommendedItems , ...virtualItems , ...globalItems ] ;
128- for ( const item of this . quickpick . items ) {
129- if ( item . description === this . service . getWorkspaceExecutable ( this . currentFolder ?. uri ?. fsPath ) ?. rBin ) {
130- this . quickpick . activeItems = [ item ] ;
139+ for ( const quickPickItem of this . quickpick . items ) {
140+ if ( ( quickPickItem as ExecutableQuickPickItem ) ?. active ) {
141+ this . quickpick . activeItems = [ quickPickItem ] ;
131142 }
132143 }
133144 }
0 commit comments