Skip to content

Feature Request: Open new file buffer via API #12283

@Jakobud

Description

@Jakobud
  • VSCode Version: 1.5.2
  • OS Version: OSX 10.10.5, Win 7 x64

Is it possible to open a new file buffer via the API? Essentially, when you use your mouse (or keyboard shortcuts) and goto File menu > New File, it creates a new Untitled file buffer in the workspace. When you Save the file, it opens a Save File dialog where you choose where to save it along with the filename. Is it possible to create a new file buffer in this same manner via the API? If not, can this feature be added?

I have messed around with the API quite a bit in this area and if it is currently possible, it's not clear in the documentation.

I know you can do this:

window.openTextDocument(Uri.parse("untitled:c:\\project\\myfile.txt"))
  .then((document) => {
    window.showTextDocument(document);
  });

But this requires that you specify the file path for this new "untitled" file. When you hit save, it forces the file to be saved at "c:\project\myfile.txt". The user is not given the chance to specify where to save the file or what filename to give it.

To make a long story short, I essentially want the same functionality as going to File menu > New File. Does that make sense?

Metadata

Metadata

Assignees

Labels

apifeature-requestRequest for new features or functionalityverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions