softUndo should be working fine with mouse based selections since the 20091023 beta - what version of Sublime Text are you using?
I’m using v1.3. I re-test this issue and I found this issue only applies to “alt+f3”, not all. Here is the step to reproduce:
- open a txt file. (I use the “Default File type.sublime-options”)
- Use mouse to move the cursor to a place. (Let’s call it place A)
- Use mouse to move the cursor to another place (place B) which has the keyword in interest.
- Press alt+f3. All the regions of this keyword will be highlighted as expected.
- Press ctrl-u. The highlighted regions will disappear, but the cursor will jump to place A, which is incorrect. I expect the cursor will jump to place B.
The behaviour you’re seeing with Alt+F3 is a byproduct of the design: when there are multiple selections, they’re all treated as equal, so when running the singleSelection command, it simply removes all of the selections bar the first one. It’d likely make more sense for singleSelection to choose the first visible region, rather than just the first. It still wouldn’t necessarily be the selection you had before pressing Alt+F3 though.
Here is what I (as a user) expected. For your reference. And hopefully you can find a solution making more sense.
From my usage point of view, singleSelection mode is only meanful when switching from multi-selection mode.
And I guess this is why singleSelection mode is default bind to “ESC” key.
IFF it is true that singleSelection is only used to switch multi-slection mode back to singleSelection mode,
then User will expect the cursor(forcus) should go back to the place where multi-selection mode begins.
Under alt+f3 case, the cursor is expected to be reverted to where the user pressed alt+f3 at beginning.
Under “ctrl+mouse_double_click multiple regions” case, the cursor is expected to be reverted to the beginning of first region switching
from singleSelect “mouse_double_click” to multi-select “ctrl+mouse_double_click”.
From my test, swiching back to singleSelection mode will always place the cursor(forcus) to the first region of the file.
From user’s point of view, the first region of the file has less meaning than the place where the multi-selection mode begins.
From my point of view, the first visible sigleSelection region also has less meaning than the place where the multi-selection mode begins.
Maybe other users can comment on their thought.
BTW, it will be great to have commands to jump cursor(forcus) back and forth.
Ctrl+u has similar function to jump cursor back, but ctrl+u is part of undo history and can not “redo”(jump forth).
It is something more lilke an “cursor forcus history”. With this feature, I can jump to a function B
define from palce A (using search or cTag or any methods which changing the cursor forcus)
and revert forcus back to place A after I finished my work in function B.
I can’t find a plugin or command for this feature.
This feature is so helpful when tracing code.