Skip to content
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 ToggleLineComment and ToggleMultilineComment service #37029

Merged
merged 22 commits into from
Jul 14, 2020

Conversation

armanio123
Copy link
Member

Implements toggleLineComment and toggleMultilineComment services. Considers jsx as well.

@typescript-bot
Copy link
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @amcasey, @mjbvz, @minestarks for you. Feel free to loop in other consumers/maintainers if necessary

src/server/protocol.ts Outdated Show resolved Hide resolved
@sandersn sandersn added the For Milestone Bug PRs that fix a bug with a specific milestone label Mar 27, 2020
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

Updating my status so I don't get nag mail about not reviewing this. 😉

@sandersn
Copy link
Member

@armanio123 @amcasey is this supposed to ship in TS 3.9 or 4.0? Is it appropriate to ship it in the RC but not the beta? There's no associated bug so I don't have a way to tell.

@minestarks
Copy link
Member

This should target 4.0 at this point.

@sandersn
Copy link
Member

What does this need to go into 4.0 now?
I can see at least it needs to merge from master.

@armanio123 armanio123 force-pushed the AddToggleCommentFeature branch from e2e4575 to 413a3d3 Compare May 23, 2020 00:38
src/server/session.ts Outdated Show resolved Hide resolved
@armanio123
Copy link
Member Author

Found a bug with uncomment that got fixed on the latest commit. This PR is ready to be merged as soon as I get an approval.

src/server/session.ts Outdated Show resolved Hide resolved
src/services/types.ts Outdated Show resolved Hide resolved
src/services/services.ts Outdated Show resolved Hide resolved
src/services/services.ts Outdated Show resolved Hide resolved
src/services/services.ts Outdated Show resolved Hide resolved
@armanio123
Copy link
Member Author

Thanks @uniqueiniquity for the review. I have addressed all of the changes. Let me know if any additional comments.

Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

I'm pretty sure there's going to be a bug tail, but I think it's better to get this out and hear from actual customers than to rathole on corner cases.

src/services/utilities.ts Show resolved Hide resolved
src/services/utilities.ts Outdated Show resolved Hide resolved
src/services/services.ts Show resolved Hide resolved
src/services/services.ts Show resolved Hide resolved
tests/cases/fourslash/commentSelection1.ts Show resolved Hide resolved

verify.toggleMultilineComment(
`let var1/* = 1;
let var2 *//*= 2;
Copy link
Member

Choose a reason for hiding this comment

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

I would be incredibly confused if this happened to me. Without having tried it, my guess would be that I'd expect the existing span to be uncommented.

Copy link
Member

Choose a reason for hiding this comment

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

On a related note, why not combine contiguous comment ranges?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is one of those scenarios that are difficult to decide the best approach.

IMO, the only reason to not merge the comments is because when we want to reverse the operation we might get a different result:. For example when using jsdoc:

[|const foo = 1;

/** some documentation 
* more doc.
*/
function bar()  {}|]

this will result on:

/*const foo = 1;

*//** some documentation 
* more doc.
*//*
function bar()  {}*/

Looks messy but in a way it respects existing comments. If you want to uncomment either foo or bar it should be ok. If we merge comments, the jsdoc syntax will be all mess up.

This is not only for jsdoc, pretty much any existing comment will experience this issue when uncommenting.

tests/cases/fourslash/uncommentSelection1.ts Show resolved Hide resolved
@armanio123 armanio123 merged commit 6279f98 into microsoft:master Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants