Skip to content

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Oct 1, 2020

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:

image

(the second option is the new one).

06needhamt and others added 30 commits December 16, 2019 12:08
…litCommentCommandHandler.cs

Co-Authored-By: CyrusNajmabadi <[email protected]>
…dHandler.CommentSplitter.vb

Co-Authored-By: CyrusNajmabadi <[email protected]>
Comment on lines 138 to 145
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();
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@sharwell sharwell left a 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.

@ghost
Copy link

ghost commented Oct 2, 2020

Hello @CyrusNajmabadi!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

public static void Main(string[] args)
{
//
//Comment
Copy link
Contributor

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?

Suggested change
//Comment
// Comment

Copy link
Member Author

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] == ' ')
Copy link
Member

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?

@ghost ghost merged commit 1464851 into dotnet:master Oct 5, 2020
@ghost ghost added this to the Next milestone Oct 5, 2020
@Cosifne Cosifne modified the milestones: Next, 16.9.P1 Oct 12, 2020
@CyrusNajmabadi CyrusNajmabadi deleted the patch-38516 branch April 11, 2021 18:24
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically comment out a new line when enter is pressed
9 participants