Skip to content

Fixed #64679 - Delete Lines now works with multiple selections on multiple lines#67287

Merged
alexdima merged 3 commits intomicrosoft:masterfrom
irrationalRock:fix-64679
Feb 19, 2019
Merged

Fixed #64679 - Delete Lines now works with multiple selections on multiple lines#67287
alexdima merged 3 commits intomicrosoft:masterfrom
irrationalRock:fix-64679

Conversation

@irrationalRock
Copy link
Contributor

This PR fixes #64679.

It now collapses all cursors:
multi-line

Also, now deletes multiple lines with multiple selections:
multi-select-line

Thanks for considering this request.

@alexdima alexdima force-pushed the fix-64679 branch 2 times, most recently from b80c785 to 1dc241a Compare February 7, 2019 11:17
Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

A few things that are not 100% good:

  • editor.executeEdits is invoked with an empty array of edits, effectively acting as if it were a call to editor.setSelections.
  • After running this action, we are now always going to 1 cursor. This is not good, e.g. when having one cursor per line -- I would expect to have here 3 cursors at the end:
Before After
kapture 2019-02-07 at 12 31 29 kapture 2019-02-07 at 12 32 47

Also, another case that is not great is when having two clusters of multiple cursors -- I would expect to have here 2 cursors at the end:

kapture 2019-02-07 at 12 28 29


All in all, tweaking the resulting selection is not the approach I would take. I would generate IIdentifiedSingleEditOperation and drop the entire DeleteLinesCommand, i.e. I would loop over all selections, and collect all lines to be deleted. I would make sure to dedup them (like a set reunion) and then issue clear edits that never overlap. I would then insert a cursor under each such deletion.

@alexdima alexdima changed the title Fixed #64679 - Delete Lines now works with multiple selections on multiple lines [WIP] Fixed #64679 - Delete Lines now works with multiple selections on multiple lines Feb 7, 2019
@irrationalRock
Copy link
Contributor Author

Thanks for the feedback, I'll go back and make the appropriate changes

@irrationalRock
Copy link
Contributor Author

So made the changes you requested.

I removed DeleteLinesCommand entirely and now issue edits to remove text.

Here is a couple of gif to show the changes.

Three Cursors:
multi-line-select-3

Two Lines with Multiple Cursors:
multi-line-select-2-multiple

My branch needs some work done on it but I wanted to see if the cursors locations after Delete Lines are good or if they need adjustment.

@alexdima alexdima changed the title [WIP] Fixed #64679 - Delete Lines now works with multiple selections on multiple lines Fixed #64679 - Delete Lines now works with multiple selections on multiple lines Feb 19, 2019
@alexdima
Copy link
Member

👍 Thank you! It was almost perfect, I just needed to add some accounting for the deleted lines in establishing the resulting cursor selection.

@alexdima alexdima added this to the February 2019 milestone Feb 19, 2019
@alexdima alexdima merged commit b666e6f into microsoft:master Feb 19, 2019
sandy081 pushed a commit to vldmrkl/vscode that referenced this pull request Feb 22, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 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.

Multicursor delete line

2 participants