Open user3323 opened 6 years ago
@alexandrudima
feature request? =\
Yes, the move or duplicate lines actions are only partially multi-cursor aware and they create bogus intersecting/conflicting edits in these cases.
Related: #41277, #40646, #19621
PR welcome in https://github.com/Microsoft/vscode/blob/1e5c0c3e4e11af82e82d7761d7875646d1c6336b/src/vs/editor/contrib/linesOperations/linesOperations.ts#L102-L104 . The current support for multi-cursor is to loop over all the selections and generate a move lines command. But a correct implementation would only invoke the command once in the case that multiple cursors sit on the same line, or that multiple cursors are within 1 line distance of each other, etc.
Hi, I am interested in this bug.
I have made some changes that partially fix this bug:
I have a question about the comment you made about this line:
for (var i = 0; i < selections.length; i++) {
commands.push(new MoveLinesCommand(selections[i], this.down, autoIndent));
}
Can you elaborate more about this? I'm wondering how you would invoke the command once instead of multiple times.
Instead of using commands (which are single-cursor aware), It is possible to use editor.executeEdits
which allows to apply N edits at the same time and set the N resulting selections.