Skip to content

Commit

Permalink
Use untitled document for nonexisting file path in cmd
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stevenguh committed Sep 2, 2019
1 parent 54165d3 commit 8f0c077
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/cmd_line/commands/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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' });
Expand Down

0 comments on commit 8f0c077

Please sign in to comment.