diff --git a/R/help/getAliases.R b/R/help/getAliases.R index 50e35fd7c..00985ea47 100644 --- a/R/help/getAliases.R +++ b/R/help/getAliases.R @@ -1,4 +1,4 @@ -requireNamespace("jsonlite") +loadNamespace("jsonlite") ip <- installed.packages() diff --git a/R/rmarkdown/templates.R b/R/rmarkdown/templates.R index dec8b97d0..93a7a0a81 100644 --- a/R/rmarkdown/templates.R +++ b/R/rmarkdown/templates.R @@ -1,5 +1,5 @@ -requireNamespace("jsonlite") -requireNamespace("yaml") +loadNamespace("jsonlite") +loadNamespace("yaml") pkgs <- .packages(all.available = TRUE) templates <- new.env() diff --git a/src/rmarkdown/draft.ts b/src/rmarkdown/draft.ts index 4a716e27e..8b1ca2193 100644 --- a/src/rmarkdown/draft.ts +++ b/src/rmarkdown/draft.ts @@ -65,6 +65,7 @@ async function getTemplateItems(cwd: string): Promise { } catch (e) { console.log(e); void window.showErrorMessage((<{ message: string }>e).message); + return undefined; } } @@ -80,8 +81,15 @@ async function launchTemplatePicker(cwd: string): Promise { const items = await getTemplateItems(cwd); - const selection: TemplateItem = await window.showQuickPick(items, options); - return selection; + if (items) { + if (items.length > 0) { + const selection = await window.showQuickPick(items, options); + return selection; + } else { + void window.showInformationMessage('No templates found.'); + } + } + return undefined; } async function makeDraft(file: string, template: TemplateItem, cwd: string): Promise {