Skip to content

Commit cb51776

Browse files
authored
Add file creation to file/newFile (#1119)
1 parent 3ed8483 commit cb51776

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,18 @@
559559
"category": "R Markdown",
560560
"command": "r.rmarkdown.newDraft"
561561
},
562+
{
563+
"title": "R Markdown (rmd)",
564+
"category": "R Markdown",
565+
"when": false,
566+
"command": "r.rmarkdown.newFileDraft"
567+
},
568+
{
569+
"title": "R Document (r)",
570+
"category": "R",
571+
"when": false,
572+
"command": "r.newFileDocument"
573+
},
562574
{
563575
"command": "r.rmarkdown.setKnitDirectory",
564576
"title": "Set Knit directory",
@@ -1237,6 +1249,16 @@
12371249
{
12381250
"command": "r.knitRmdToAll"
12391251
}
1252+
],
1253+
"file/newFile": [
1254+
{
1255+
"group": "R",
1256+
"command": "r.rmarkdown.newFileDraft"
1257+
},
1258+
{
1259+
"group": "R",
1260+
"command": "r.newFileDocument"
1261+
}
12401262
]
12411263
},
12421264
"submenus": [

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<apiImp
105105
'r.rmarkdown.preview.enableAutoRefresh': () => rmdPreviewManager.enableAutoRefresh(),
106106
'r.rmarkdown.preview.disableAutoRefresh': () => rmdPreviewManager.disableAutoRefresh(),
107107

108+
// file creation (under file submenu)
109+
'r.rmarkdown.newFileDraft': () => rmarkdown.newDraft(),
110+
'r.newFileDocument': () => vscode.workspace.openTextDocument({language: 'r'}).then((v) => vscode.window.showTextDocument(v)),
111+
108112
// editor independent commands
109113
'r.createGitignore': rGitignore.createGitignore,
110114
'r.loadAll': () => rTerminal.runTextInTerm('devtools::load_all()'),

src/rmarkdown/draft.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export async function newDraft(): Promise<void> {
132132
const parsedPath = path.parse(uri.fsPath);
133133
const dir = path.join(parsedPath.dir, parsedPath.name);
134134
if (fs.existsSync(dir)) {
135-
if (await getConfirmation(`Folder already exists. Are you sure to replace the folder?`)) {
135+
if (await getConfirmation(`Folder already exists. Are you sure you want to replace the folder?`)) {
136136
fs.rmdirSync(dir, { recursive: true });
137137
} else {
138138
return;

0 commit comments

Comments
 (0)