fix: multi cursor copy line n times (#40646) #52645
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#40646
This commit introduces filtering of current selections for copy line actions
Current behaviour: When multiple cursors are being added to single line on copy line action the content of a line is being duplicated. The amount of copied lines is equal to the number of cursors in line that is being copied.
After filtering:
selectionsarray is filtered before runningCopyLinesCommandto avoid the duplication.Unfortunately for now the
Selectionsafter the copy action are not predictable and showing in not expected places as I wasn't able to figure out yet how to useeditor.setSelectionoreditor.setSelectionsproperly.Also it would be good to agree on expected behaviour for the copy actions with multiple selectors so some test around it could be created as well.
I would appreciate any advice and links relevant to setting the position of multiple cursors.
I was thinking of looping over the selections array after the executeCommands will finish running and set the position to line below the initial selection, but not sure if that's best way to approach this.