-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: OpenTextDocument with content #21413
Comments
@hoovercj why are steps 1 and 2 needed if all you need is the content of a file? |
Sorry @bpasero for the poorly worded issue, I've updated it to clarify that those were 3 distinct options. |
@hoovercj nothing prevents you from opening an untitled file and then setting the content, right? |
@bpasero I didn't see a way to set the content without doing an insert textedit which would allow the user to From the user perspective, "open example" should be a discrete step. If they make some modifications and want to quickly get back to the original document they can't blindly press "undo" right now because they would get back to a blank page and then have to press "redo" and hope they don't accidentally press a key and then lose the document and need to "open example" again. Of course, if there is a different way that I've missed to set the document content that doesn't result in an undo, I might be able to use that instead |
Ok, good point about the undo. |
@jrieken fyi I think we would be open to a PR here if you are willing to look into it. |
Yeah, would be straight forward to pass on a string when calling the open function |
@jrieken please verify |
#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:
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 likeThe text was updated successfully, but these errors were encountered: