Skip to content

Implement multiple mouse selections with multicursor

Waqar Ahmed requested to merge work/multimousecursors into master

This change adds the ability to create multiple selections using mouse. As a side effect of the change, a couple of other bugs got fixed as well

Implementation is relatively simple. Instead of creating a cursor and then tracking its state through various functions, I used a different approach which makes things very easy to implement. Whenever the user creates a cursor, make the new cursor our primary cursor. By doing this, we can reuse existing mouse selection implementation.

However, with this feature we can now have have N cursors and M selections which creates some new problems. For e.g., if there are 2 selections and a third cursor without selection, what should happen on backspace? For now, I chose to go the sublime text route i.e., only selections will get removed, the cursor without selection will stay where it was.

If you have multiple selections and you want to remove one, you can just Alt+Click on the selection and it will be removed. Previously this only worked if you clicked exactly on the cursor.

Tests have been extended to cover newly added things but I think we still need a few more tests for multiple cursors.

Signed-off-by: Waqar Ahmed waqar.17a@gmail.com


Bugs that got fixed:

  • Delete key press with multiple selections will now work correctly
  • Up/Down movements will now correctly merge cursors

Further improvements:

  • Paint secondary selections as we paint our primary one so that they look the same
  • Support keeping multiple cursors on large movements such as page down/go to top etc
Edited by Waqar Ahmed

Merge request reports

Loading