MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / setKnitDir

Method setKnitDir

src/rmarkdown/knit.ts:193–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191
192 // alters the working directory for evaluating chunks
193 public setKnitDir(): void {
194 const textEditor = vscode.window.activeTextEditor;
195 const currentDocumentWorkspacePath: string | undefined = textEditor ? vscode.workspace.getWorkspaceFolder(textEditor.document.uri)?.uri.fsPath : undefined;
196 const currentDocumentFolderPath: string | undefined = textEditor ? path.dirname(textEditor.document.uri.fsPath) : undefined;
197 const items: IKnitQuickPickItem[] = [];
198
199 if (currentDocumentWorkspacePath) {
200 items.push(
201 {
202 label: (knitDir === KnitWorkingDirectory.workspaceRoot ? '$(check)' : '') + KnitWorkingDirectory.workspaceRoot,
203 value: KnitWorkingDirectory.workspaceRoot,
204 detail: 'Use the workspace root as the knit working directory',
205 description: currentDocumentWorkspacePath ?? currentDocumentFolderPath ?? 'No available workspace'
206 }
207 );
208 }
209
210 if (currentDocumentFolderPath && currentDocumentFolderPath !== '.') {
211 items.push(
212 {
213 label: (knitDir === KnitWorkingDirectory.documentDirectory ? '$(check)' : '') + KnitWorkingDirectory.documentDirectory,
214 value: KnitWorkingDirectory.documentDirectory,
215 detail: 'Use the document\'s directory as the knit working directory',
216 description: currentDocumentFolderPath ?? 'No folder available'
217
218 }
219 );
220 }
221
222 if (items.length > 0) {
223 void vscode.window.showQuickPick(
224 items,
225 {
226 title: 'Set knit working directory',
227 canPickMany: false
228 }
229 ).then(async choice => {
230 if (choice?.value && knitDir !== choice.value) {
231 knitDir = choice.value;
232 await rmdPreviewManager?.updatePreview();
233 }
234 });
235 } else {
236 void vscode.window.showInformationMessage('Cannot set knit directory for untitled documents.');
237 }
238
239 }
240
241 public async knitRmd(echo: boolean, outputFormat?: string): Promise<void> {
242 const textEditor = vscode.window.activeTextEditor;

Callers 1

activateFunction · 0.80

Calls 1

updatePreviewMethod · 0.80

Tested by

no test coverage detected