Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rmarkdown/knit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class RMarkdownKnitManager extends RMarkdownManager {

return await this.knitWithProgress(
{
workingDirectory: knitWorkingDir,
fileName: docName,
filePath: rDocumentPath,
scriptArgs: scriptValues,
Expand Down
10 changes: 6 additions & 4 deletions src/rmarkdown/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IKnitRejection {
const rMarkdownOutput: vscode.OutputChannel = vscode.window.createOutputChannel('R Markdown');

interface IKnitArgs {
workingDirectory: string;
filePath: string;
fileName: string;
scriptArgs: Record<string, string>;
Expand All @@ -35,15 +36,15 @@ export abstract class RMarkdownManager {
// so that we can't spam the knit/preview button
protected busyUriStore: Set<string> = new Set<string>();

protected getKnitDir(knitDir: string, docPath?: string): string {
const currentDocumentWorkspace = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(docPath) ?? vscode.window.activeTextEditor?.document?.uri)?.uri?.fsPath ?? undefined;
protected getKnitDir(knitDir: string, docPath: string): string {
switch (knitDir) {
// the directory containing the R Markdown document
case KnitWorkingDirectory.documentDirectory: {
return path.dirname(docPath).replace(/\\/g, '/').replace(/['"]/g, '\\"');
}
// the root of the current workspace
case KnitWorkingDirectory.workspaceRoot: {
const currentDocumentWorkspace = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(docPath) ?? vscode.window.activeTextEditor?.document?.uri)?.uri?.fsPath ?? undefined;
return currentDocumentWorkspace.replace(/\\/g, '/').replace(/['"]/g, '\\"');
}
// the working directory of the attached terminal, NYI
Expand Down Expand Up @@ -74,11 +75,12 @@ export abstract class RMarkdownManager {
`-f`,
`${scriptPath}`
];
const processOptions = {
const processOptions: cp.SpawnOptions = {
env: {
...process.env,
...scriptArgs
}
},
cwd: args.workingDirectory,
};

let childProcess: DisposableProcess;
Expand Down
1 change: 1 addition & 0 deletions src/rmarkdown/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ export class RMarkdownPreviewManager extends RMarkdownManager {

return await this.knitWithProgress(
{
workingDirectory: knitWorkingDir,
fileName: fileName,
filePath: filePath,
scriptPath: extensionContext.asAbsolutePath('R/rmarkdown/preview.R'),
Expand Down