Skip to content

Commit 8f0c077

Browse files
committed
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.
1 parent 54165d3 commit 8f0c077

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

src/cmd_line/commands/file.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ async function doesFileExist(fileUri: vscode.Uri) {
2222
}
2323
}
2424

25-
async function createNewFile(fileUri: vscode.Uri) {
26-
const activeTextEditor = vscode.window.activeTextEditor;
27-
if (activeTextEditor) {
28-
await vscode.workspace.fs.writeFile(fileUri, new Uint8Array());
29-
} else {
30-
// fallback to local fs
31-
await util.promisify(fs.close)(await util.promisify(fs.open)(fileUri.fsPath, 'w'));
32-
}
33-
}
34-
3525
export enum FilePosition {
3626
NewWindowVerticalSplit,
3727
NewWindowHorizontalSplit,
@@ -149,9 +139,6 @@ export class FileCommand extends node.CommandBase {
149139
// If both with and without ext path do not exist
150140
if (!fileExists) {
151141
if (this.arguments.createFileIfNotExists) {
152-
await createNewFile(uriPath);
153-
fileUri = uriPath;
154-
} else {
155142
// Change the scheme to untitled to open an
156143
// untitled tab
157144
fileUri = uriPath.with({ scheme: 'untitled' });

0 commit comments

Comments
 (0)