bigfive / atom-sublime-select

Enable 'sublime style' multiline selection boxes to Atom editor http://atom.io
MIT License
233 stars 49 forks source link

Example of writing a plugin to cope with multiple selections? #148

Open gingerbeardman opened 7 years ago

gingerbeardman commented 7 years ago

As it is every plugin I've used that operates on a selection replaces all selections with the results of its work on the first selection.

bigfive commented 5 years ago

Hi, are you asking how you might go about creating a plugin that leaves any existing sections alone?

The line that replaces the selections is here https://github.com/bigfive/atom-sublime-select/blob/master/lib/editor-handler.coffee#L133

I imagine you would want to read all the existing selection ranges on mouse down, then add those existing selection ranges to the new ones added during _selectBoxAroundCursors.

If you manage it, I'd love to take a look. We could make it an optional feature.