-
Notifications
You must be signed in to change notification settings - Fork 28.7k
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
Add ability to open untitled document with initial content #22021
Conversation
@hoovercj, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bpasero and @alexandrudima to be potential reviewers. |
@hoovercj, |
@hoovercj thanks. /cc @jrieken for the API change |
@@ -100,6 +100,15 @@ suite('workspace-namespace', () => { | |||
}); | |||
}); | |||
|
|||
test('openTextDocument, untitled without path but language ID and contents', function () { | |||
return workspace.openTextDocument({ language: 'html', contents: '<h1>Hello world!</h1>' }).then(doc => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
singular, content
?
@@ -4085,7 +4085,7 @@ declare module 'vscode' { | |||
* @param options Options to control how the document will be created. | |||
* @return A promise that resolves to a [document](#TextDocument). | |||
*/ | |||
export function openTextDocument(options?: { language: string; }): Thenable<TextDocument>; | |||
export function openTextDocument(options?: { language?: string; contents?: string; }): Thenable<TextDocument>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing jsdoc-comment, also use content
to align with TextDocumentContentProvider
re #22021 (comment) - that's a personal preference ;-) For me, private fields are underscore-prefixed because that helps me read method bodies. Others use underscore only if a property would collide with a getter/setter otherwise. |
As a rule of thumb, when adding to existing code, we should not start a new style but apply the style the code was originally written in. @hoovercj since I already merged this change, I suggest a new PR just for the 💄 changes. |
@bpasero I agree with the consistent style comment. I was confused by Regarding a new PR, you are suggesting that I make a new PR that changes contents to content, adds a jsdoc comment, etc.? I can hopefully get to that tonight. |
@hoovercj |
Yep, now I see that, and that |
Follow up to PR #22021 to respond to feedback
Addresses #21413 by passing file contents down to the
UntitledEditorModel
.I checked that it worked locally and I added a test case, but I've had issues getting tests to run as reported in #22019.