Skip to content

Commit 37a3a09

Browse files
committed
Task rpath, path settings machine-overridable
- rpath is machine-overridable - task rpath dependent on active workspace executable - quickpick shows arrow for active path
1 parent c7f6b87 commit 37a3a09

File tree

11 files changed

+60
-53
lines changed

11 files changed

+60
-53
lines changed

package.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,32 +1286,38 @@
12861286
"r.rpath.windows": {
12871287
"type": "string",
12881288
"default": "",
1289-
"description": "Path to an R executable for Windows. Must be \"vanilla\" R, not radian etc.!"
1289+
"description": "Path to an R executable for Windows. Must be \"vanilla\" R, not radian etc.!",
1290+
"scope": "machine-overridable"
12901291
},
12911292
"r.rpath.mac": {
12921293
"type": "string",
12931294
"default": "",
1294-
"description": "Path to an R executable for macOS. Must be \"vanilla\" R, not radian etc.!"
1295+
"description": "Path to an R executable for macOS. Must be \"vanilla\" R, not radian etc.!",
1296+
"scope": "machine-overridable"
12951297
},
12961298
"r.rpath.linux": {
12971299
"type": "string",
12981300
"default": "",
1299-
"description": "Path to an R executable for Linux. Must be \"vanilla\" R, not radian etc.!"
1301+
"description": "Path to an R executable for Linux. Must be \"vanilla\" R, not radian etc.!",
1302+
"scope": "machine-overridable"
13001303
},
13011304
"r.rterm.windows": {
13021305
"type": "string",
13031306
"default": "",
1304-
"description": "R path for Windows. Can also be radian etc."
1307+
"description": "R path for Windows. Can also be radian etc.",
1308+
"scope": "machine-overridable"
13051309
},
13061310
"r.rterm.mac": {
13071311
"type": "string",
13081312
"default": "",
1309-
"description": "R path for macOS. Can also be radian etc."
1313+
"description": "R path for macOS. Can also be radian etc.",
1314+
"scope": "machine-overridable"
13101315
},
13111316
"r.rterm.linux": {
13121317
"type": "string",
13131318
"default": "",
1314-
"description": "R path for Linux. Can also be radian etc."
1319+
"description": "R path for Linux. Can also be radian etc.",
1320+
"scope": "machine-overridable"
13151321
},
13161322
"r.rterm.option": {
13171323
"type": "array",

src/executables/index.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import * as vscode from 'vscode';
55
import { ExecutableStatusItem, ExecutableQuickPick } from './ui';
66
import { isVirtual, RExecutableService, ExecutableType, WorkspaceExecutableEvent } from './service';
77
import { extensionContext } from '../extension';
8-
import { activateCondaEnvironment } from './conda';
9-
10-
export { ExecutableType as IRExecutable, VirtualExecutableType as IVirtualRExecutable } from './service';
8+
import { activateCondaEnvironment } from './virtual';
119

1210
// super class that manages relevant sub classes
13-
export class RExecutableManager implements vscode.Disposable {
11+
export class RExecutableManager {
1412
private readonly executableService: RExecutableService;
1513
private statusBar: ExecutableStatusItem;
1614
private quickPick: ExecutableQuickPick;
@@ -28,7 +26,9 @@ export class RExecutableManager implements vscode.Disposable {
2826
this.reload();
2927
}
3028
}),
31-
this
29+
this.executableService,
30+
this.statusBar,
31+
this.quickPick
3232
);
3333
this.reload();
3434
}
@@ -38,12 +38,6 @@ export class RExecutableManager implements vscode.Disposable {
3838
return new this(executableService);
3939
}
4040

41-
public dispose(): void {
42-
this.executableService.dispose();
43-
this.statusBar.dispose();
44-
this.quickPick.dispose();
45-
}
46-
4741
public get executableQuickPick(): ExecutableQuickPick {
4842
return this.quickPick;
4943
}

src/executables/service/class.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { getCondaName, getRDetailsFromMetaHistory, isCondaInstallation } from '../conda';
1+
import { getCondaName, getRDetailsFromMetaHistory, isCondaInstallation } from '../virtual';
22
import { getRDetailsFromPath } from './locator';
33
import { RExecutableRegistry } from './registry';
4-
import { IExecutableDetails, ExecutableType } from './types';
4+
import { ExecutableType } from './types';
55

66
export function isVirtual(executable: AbstractExecutable): executable is VirtualRExecutable {
77
return executable instanceof VirtualRExecutable;
@@ -65,10 +65,6 @@ export class RExecutable extends AbstractExecutable {
6565
}
6666
return `$(error) R`;
6767
}
68-
69-
protected getDetailsFromPath(execPath: string): IExecutableDetails {
70-
return getRDetailsFromPath(execPath);
71-
}
7268
}
7369

7470
export class VirtualRExecutable extends AbstractExecutable {

src/executables/service/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { config, getCurrentWorkspaceFolder, getRPathConfigEntry } from '../../ut
66
import { RExecutablePathStorage } from './pathStorage';
77
import { RExecutableRegistry } from './registry';
88
import { AbstractLocatorService, LocatorServiceFactory } from './locator';
9-
import { getRenvVersion } from './renv';
9+
import { getRenvVersion } from '../virtual';
1010
import { ExecutableType, WorkspaceExecutableEvent } from './types';
1111

1212
export * from './types';

src/executables/service/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as vscode from 'vscode';
33
import { AbstractExecutable, VirtualRExecutable } from './class';
44

55
export type ExecutableType = AbstractExecutable;
6-
76
export type VirtualExecutableType = VirtualRExecutable;
87

98
export interface IExecutableDetails {

src/executables/ui/quickpick.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { validateRExecutablePath } from '..';
66
import { config, getCurrentWorkspaceFolder, getRPathConfigEntry, isMultiRoot } from '../../util';
77
import { isVirtual, ExecutableType } from '../service';
88
import { RExecutableService } from '../service';
9-
import { getRenvVersion } from '../service/renv';
9+
import { getRenvVersion } from '../virtual';
1010

1111
class 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

4652
enum 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
}

src/executables/ui/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class ExecutableStatusItem implements vscode.Disposable {
1313
private languageStatusItem: vscode.LanguageStatusItem;
1414

1515
private createItem(): vscode.LanguageStatusItem {
16-
this.languageStatusItem = vscode.languages.createLanguageStatusItem('R Executable Selector', ['r', 'rmd']);
16+
this.languageStatusItem = vscode.languages.createLanguageStatusItem('R Executable Selector', ['r', 'rmd', 'rProfile']);
1717
this.languageStatusItem.name = 'R Language Service';
1818
this.languageStatusItem.command = {
1919
'title': 'Select R executable',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { IExecutableDetails } from './service';
2+
import { IExecutableDetails } from '../service';
33
import * as fs from 'fs-extra';
44
import * as vscode from 'vscode';
55
import path = require('path');

src/executables/virtual/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './conda';
2+
export * from './renv';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path = require('path');
2-
import { IRenvLock } from './types';
2+
import { IRenvLock } from '../service/types';
33
import * as fs from 'fs-extra';
44

55
export function getRenvVersion(workspacePath: string): string | undefined {

0 commit comments

Comments
 (0)