-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Comment out a new line when return is pressed while the caret is within a // comment #48217
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
Conversation
…litCommentCommandHandler.cs Co-Authored-By: CyrusNajmabadi <[email protected]>
…dHandler.CommentSplitter.vb Co-Authored-By: CyrusNajmabadi <[email protected]>
…ler.CommentSplitter.cs Co-Authored-By: CyrusNajmabadi <[email protected]>
…ler.cs Co-Authored-By: CyrusNajmabadi <[email protected]>
…ler.CommentSplitter.cs Co-authored-by: CyrusNajmabadi <[email protected]>
…mmentService.vb Co-authored-by: Sam Harwell <[email protected]>
using var transaction = CaretPreservingEditTransaction.TryCreate( | ||
EditorFeaturesResources.Split_comment, textView, _undoHistoryRegistry, _editorOperationsFactoryService); | ||
|
||
subjectBuffer.Replace( | ||
GetReplacementSpan(triviaLine, position), | ||
GetReplacementText(textView, document, options, triviaLine, trivia, position)); | ||
|
||
transaction.Complete(); |
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.
❔ Does this need to be on the main thread?
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.
that is a good question. I observe no bad behavior doing things this way... but it is somewhat suspect. Wondering if @jasonmalinowski or @olegtk might know... i can rejigger this though just to be safe in the meantime.
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.
My review focused on tests. Another review of the implementation would be good.
Hello @CyrusNajmabadi! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
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.
Auto-approval
4ba8bb9
to
2c05b36
Compare
public static void Main(string[] args) | ||
{ | ||
// | ||
//Comment |
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.
Shouldn't there be a space between slashes and Comment
?
//Comment | |
// Comment |
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.
I took the policy that left point of the selection helped indicate how much space to consume.
while (replacementStart > triviaLine.Start && textSnapshot[replacementStart - 1] == ' ') | ||
replacementStart--; | ||
|
||
while (replacementEnd < triviaLine.End && textSnapshot[replacementEnd] == ' ') |
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.
Should this consume tabs too?
Supersedes #40408
Fixes #38516
Mirror the string literal splitting logic to split single line comments when return is pressed.
UI for this looks like this:
(the second option is the new one).