Skip to content

Add ability to open untitled document with initial content#22021

Merged
bpasero merged 2 commits intomicrosoft:masterfrom
hoovercj:openWithContent
Mar 7, 2017
Merged

Add ability to open untitled document with initial content#22021
bpasero merged 2 commits intomicrosoft:masterfrom
hoovercj:openWithContent

Conversation

@hoovercj
Copy link
Member

@hoovercj hoovercj commented Mar 5, 2017

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.

@mention-bot
Copy link

@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.

@msftclas
Copy link

msftclas commented Mar 5, 2017

@hoovercj,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@bpasero bpasero self-assigned this Mar 5, 2017
@bpasero bpasero added this to the March 2017 milestone Mar 7, 2017
@bpasero bpasero merged commit 503f8f5 into microsoft:master Mar 7, 2017
@bpasero
Copy link
Member

bpasero commented Mar 7, 2017

@hoovercj thanks.

/cc @jrieken for the API change

});

test('openTextDocument, untitled without path but language ID and contents', function () {
return workspace.openTextDocument({ language: 'html', contents: '<h1>Hello world!</h1>' }).then(doc => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

singular, content?

* @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>;
Copy link
Member

@jrieken jrieken Mar 7, 2017

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

@jrieken
Copy link
Member

jrieken commented Mar 7, 2017

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.

@bpasero
Copy link
Member

bpasero commented Mar 7, 2017

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.

@hoovercj
Copy link
Member Author

hoovercj commented Mar 7, 2017

@bpasero I agree with the consistent style comment. I was confused by _hasAssociatedFilePath which does have the leading _. To me the initial value seems closer to _hasAssociatedFilePath than modeId so I also used a leading _.

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.

@bpasero
Copy link
Member

bpasero commented Mar 7, 2017

@hoovercj _hasAssociatedFilePath makes sense because of the getter for it.

@hoovercj
Copy link
Member Author

hoovercj commented Mar 7, 2017

Yep, now I see that, and that modeId doesn't have a getter, it has getModeId(). No name conflict so no _. Thanks for the clarification

hoovercj pushed a commit to hoovercj/vscode that referenced this pull request Mar 7, 2017
bpasero added a commit that referenced this pull request Mar 8, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants