When Alt+Dragging, there seems to be spurious SCN_UPDATEUI notifications carrying the SC_UPDATE_SELECTION flag.
Steps to reproduce:
Alt+Drag to make a rectangular selectionSCN_UPDATEUI notifications are generated (this is fine)SCN_UPDATEUI notifications per second.Shift+Alt+ArrowsI have reproduce this on Win7 using:
Automatic scrolling while mouse is down is performed on timer ticks as if the user is moving the mouse.
Ah OK. That makes a bit more sense now.
If you are interested, I've made a minor modification to Editor::ButtonMoveWithModifiers() that appears to fix the issue in a couple of cases I've noticed (rectangular selection and multilpe selections) by checking first the the position has actually changed before the selection gets changed and invalidated.
I've attached the new Editor::ButtonMoveWithModifiers() method. This was made on the v3.8 release. Guessing it will carry over to v4.0+ fine.
SCN_UPDATEUI with SC_UPDATE_SELECTION notifications are meant for updating ancillary UI elements to match the state of Scintilla. A common example is showing the current position in a status bar. This feature was not designed to reflect selection changes accurately. Instead it should be seen as a hint that a change may have occurred. Attempts to use this as meaning that the selection has definitely changed will not work. I will update the documentation to reflect this.
Eliminating all unnecessary SC_UPDATE_SELECTION notifications appears to me to be difficult and fragile and will increase code complexity.
That explanation is sufficient for me. And updating the documentation will help clarify the intent of the notification. Thanks!
Updated the documentation with [3f20ba].
The code has some poor layering currently. ButtonMoveWithModifiers should just classify the mouse movement and pass up to a SetSelection* method that joins keyboard and mouse (and potentially other) input events into logical events. This is what happens for simple selections but the rectangular and multiple-selection cases add irregular selection manipulation inside ButtonMoveWithModifiers. The SC_UPDATE_SELECTION notification is triggered in InvalidateSelection which is called somewhat liberally for complex selection cases since it is difficult to calculate the exact area that has changed from unselected to selected (or reverse) so needs redrawing.
It may be possible for the patch to change behaviour for the worse in unusual circumstances, such as background styling, where the text layout is changing asynchronously while the mouse is down. Understanding any problems would take more time and effort than appear justified by the patch's benefits.
I have marked this issue as 'rejected' as improving this code is low priority.
Related
Commit: [3f20ba]