Skip to content

Commit 942a4d4

Browse files
Tal500Tal Hadad
andauthored
allow to invoke R terminal also in relative paths (#1398)
* allow to invoke R terminal also in relative paths, and specify the right working directory for the workspace * remove code duplication --------- Co-authored-by: Tal Hadad <thadad@istraresearch.com>
1 parent a66414b commit 942a4d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/rTerminal.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as util from './util';
1010
import * as selection from './selection';
1111
import { getSelection } from './selection';
1212
import { cleanupSession } from './session';
13-
import { config, delay, getRterm } from './util';
13+
import { config, delay, getRterm, getCurrentWorkspaceFolder } from './util';
1414
import { rGuestService, isGuestSession } from './liveShare';
1515
import * as fs from 'fs';
1616
export let rTerm: vscode.Terminal | undefined = undefined;
@@ -115,12 +115,17 @@ export async function runFromLineToEnd(): Promise<void> {
115115
}
116116

117117
export async function makeTerminalOptions(): Promise<vscode.TerminalOptions> {
118-
const termPath = await getRterm();
118+
const workspaceFolderPath = getCurrentWorkspaceFolder()?.uri.fsPath;
119+
const termPathMaybeRelative = await getRterm();
120+
const termPath: string | undefined = (workspaceFolderPath && termPathMaybeRelative) ?
121+
path.resolve(workspaceFolderPath, termPathMaybeRelative) :
122+
termPathMaybeRelative;
119123
const shellArgs: string[] = config().get('rterm.option') || [];
120124
const termOptions: vscode.TerminalOptions = {
121125
name: 'R Interactive',
122126
shellPath: termPath,
123127
shellArgs: shellArgs,
128+
cwd: workspaceFolderPath,
124129
};
125130
const newRprofile = extensionContext.asAbsolutePath(path.join('R', 'session', 'profile.R'));
126131
const initR = extensionContext.asAbsolutePath(path.join('R', 'session','init.R'));

0 commit comments

Comments
 (0)