Skip to content

Leave selection unchanged when toggling line comment#51493

Merged
dibarbet merged 1 commit intodotnet:masterfrom
dibarbet:toggle_line_leave_selection
Feb 25, 2021
Merged

Leave selection unchanged when toggling line comment#51493
dibarbet merged 1 commit intodotnet:masterfrom
dibarbet:toggle_line_leave_selection

Conversation

@dibarbet
Copy link
Copy Markdown
Member

Forked from #51411

Resolves #36349

@dibarbet
Copy link
Copy Markdown
Member Author

thanks @ryzngard !

@dibarbet dibarbet merged commit e34da07 into dotnet:master Feb 25, 2021
@ghost ghost added this to the Next milestone Feb 25, 2021
@dibarbet dibarbet deleted the toggle_line_leave_selection branch February 25, 2021 23:03
Copy link
Copy Markdown

@justcla justcla left a comment

Choose a reason for hiding this comment

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

When applying ToggleLineComment to a selection, the start of the selection should not change. Current tests move the caret two places to the left to include the comment markers. This is not expected behaviour.

void M()
{
[| ////var i = 1;
[|////var i = 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This has changed the selection by including the comment markers inside the selection. This is not the behaviour intended.

void M()
{
[| //var i = 1;
[|//var i = 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The start marker of the selection should remain as it was - immediately left of "var".

void M()
{
[| //var i = 1;|]
[|//var i = 1;|]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This has moved the caret. Suggest leaving the caret unchanged (as per spec).
Caret should be hard left against "var".

void M()
{
[| //var i = 1; // A comment.|]
[|//var i = 1; // A comment.|]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This has moved the caret and changed the selection. Please leave the selection unchanged. Caret should remain hard left against "var", which is where it was before applying the action.

void M()
{
[| //string s = '\\';|]
[|//string s = '\\';|]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This has changed the selection by adding extra chars at the beginning.
Please leave the selection unchanged by keeping the caret immediately to the left of "string".

void M()
{
[| //var i = 1; // A comment.
[|//var i = 1; // A comment.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Selection start should remain the same - right next to "var".

@dibarbet
Copy link
Copy Markdown
Member Author

@justcla thanks for the feedback. I'm not totally sure I agree with not including the comment marker. When there is a subsection of the line selected I think it makes sense to leave the selection as it was (so you can easily change a variable name or something similar). However having the selection include the comment marker when the whole line is selected seems to make sense to me.

I'll try out your suggestion and play around with both options for an hour or two to see which one feels better.

@justcla
Copy link
Copy Markdown

justcla commented Feb 26, 2021

Thanks Dave. I agree with you.
I spoke out too soon. We are on the same page. Please disregard my comments on that issue.

@justcla
Copy link
Copy Markdown

justcla commented Feb 26, 2021

I still think there is an issue with adding comment markers anywhere but the beginning of the line.

When you apply comment markers one line at a time in an indented section, the comments will be scattered.
When you pre-select the area and apply comment markers, they are lined up - but, somewhat randomly in line with the earliest char on any of the lines. This is begging for inconsistency in how and where the comment marker will be applied.

Applying line comment markers at the start of the line provides consistency. And furthermore... why not? The user has asked to comment the entire line. So why start a comment some 'random' number of chars in?

@allisonchou allisonchou modified the milestones: Next, 16.10.P2 Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leave selection unchanged when applying ToggleLineComment

4 participants