When changing the margin width (any margin), the memorized X position of the caret doesn't get adjusted properly, a vertical change then jumps to the wrong horizontal position.
Steps to reproduce:
This is because the last X position is remembered in pixels from the left of the window including all margins, but isn't updated when any margin changes (by SCI_SETMARGINWIDTHN). I came across this problem in the Notepad++ bug tracker, it happens there f.e. when going from 3 digit to 4 digit line numbers and the margin width is automatically adjusted.
There is another margin that can be changed with SCI_SETMARGINLEFT, it has the same problem. This one is mostly constant after initialization, but since I'm at it...
To reproduce it, do this:
This problem is in all revisions up to and including 53b22698a1b0 (the current one at the time of this report). The attached patch consists of basically two one-liners that adjust the memorized position by the amount of change in both places.
A similar problem exists when the zoom level is changed, the memorized X position is not adjusted. But fixing this one is not as simple if rounding errors must be avoided (f.e. zooming in or out n steps and back again should result in the same X position as before), therefore I left it as is.
Committed as [521c6c].
Related
Commit: [521c6c]