From 8f0c077ef1fa6d93b19698dc34a7192d9c5afbd1 Mon Sep 17 00:00:00 2001 From: Steven Guh Date: Mon, 2 Sep 2019 15:35:51 +0800 Subject: [PATCH] Use untitled document for nonexisting file path in cmd In the actual Vim, commands like ":e" do not create a file first if the path in the cmd doesn't exist. Rather, it creates an empty buffer and only create the file on write. This commits changes the behavior to be more consistent with actual Vim by using untitled document instead creating the file if the file on the cmd is not found. --- src/cmd_line/commands/file.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/cmd_line/commands/file.ts b/src/cmd_line/commands/file.ts index 249fbf545514..ab49dee50dd5 100644 --- a/src/cmd_line/commands/file.ts +++ b/src/cmd_line/commands/file.ts @@ -22,16 +22,6 @@ async function doesFileExist(fileUri: vscode.Uri) { } } -async function createNewFile(fileUri: vscode.Uri) { - const activeTextEditor = vscode.window.activeTextEditor; - if (activeTextEditor) { - await vscode.workspace.fs.writeFile(fileUri, new Uint8Array()); - } else { - // fallback to local fs - await util.promisify(fs.close)(await util.promisify(fs.open)(fileUri.fsPath, 'w')); - } -} - export enum FilePosition { NewWindowVerticalSplit, NewWindowHorizontalSplit, @@ -149,9 +139,6 @@ export class FileCommand extends node.CommandBase { // If both with and without ext path do not exist if (!fileExists) { if (this.arguments.createFileIfNotExists) { - await createNewFile(uriPath); - fileUri = uriPath; - } else { // Change the scheme to untitled to open an // untitled tab fileUri = uriPath.with({ scheme: 'untitled' });