Skip to content

Feature Request: OpenTextDocument with content #21413

@hoovercj

Description

@hoovercj

#12283 added an api overload to open a new, untitled text document with an optional language mode.

It would be great if this could be augmented to accept content.

Use case: I have an extension that ships with examples. Currently I have to do one of the following:

  • Open the "source" file directly which would allow users to clobber it
  • Copy the file to a temp file and open that and then remember to clean it up. Users would still have to "save as" to save it in a location that is useful to them
  • Use the new overload to open an untitled, empty text document and then use an edit to populate the contents.

The last one is the most viable but seems unnecessary. I would like to see openTextDocument(options?: {language: id, content: text}) so I could do something like

openTextDocument(exampleUri).then(exampleDocument => { const exampleText = exampleDocument.getText(); openTextDocument({language: LANG_ID, content: exampleText})

Metadata

Metadata

Assignees

Labels

apifeature-requestRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunitiesverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions