Request for SCI_SETUNDOSELECTIONHISTORY to make top line restoration optional

41 views
Skip to first unread message

Mitchell

unread,
Apr 14, 2025, 9:40:23 AMApr 14
to scintilla-interest
Hi Neil,

Currently, when SCI_SETUNDOSELECTIONHISTORY is enabled, undo restores both the selection and the top line (scroll) position. Can we add either an option or a bit-field to disable the latter? I find it quite jarring when I’ve scrolled the view a little bit and press undo, only to have my scroll position reset.

Thanks for your consideration!

Cheers,
Mitchell

Mitchell

unread,
Apr 15, 2025, 12:21:29 AMApr 15
to scintilla...@googlegroups.com
Hi,

> On Apr 14, 2025, at 9:40 AM, Mitchell <co...@foicica.com> wrote:
>
> Hi Neil,
>
> Currently, when SCI_SETUNDOSELECTIONHISTORY is enabled, undo restores both the selection and the top line (scroll) position. Can we add either an option or a bit-field to disable the latter? I find it quite jarring when I’ve scrolled the view a little bit and press undo, only to have my scroll position reset.

After thinking more on this, if the caret is outside the view, I’m fine restoring the scroll position. If the caret is in view, I’d prefer that the scroll position remain unchanged.

Cheers,
Mitchell

Neil Hodgson

unread,
Apr 17, 2025, 7:55:56 PMApr 17
to scintilla-interest
Mitchell:
 
Currently, when SCI_SETUNDOSELECTIONHISTORY is enabled, undo restores both the selection and the top line (scroll) position. Can we add either an option or a bit-field to disable the latter?

Yes. Added SC_UNDO_SELECTION_HISTORY_SCROLL to control whether the vertical scroll position is restored.

This is an incompatible change in the sense that applications will need to set SC_UNDO_SELECTION_HISTORY_SCROLL | SC_UNDO_SELECTION_HISTORY_ENABLED to produce the previous behaviour. If this causes too much trouble for anyone, it could be replaced with a negation option ..._HISTORY_NO_SCROLL but negation flags are much less clear.

> After thinking more on this, if the caret is outside the view, I’m fine restoring the scroll position. If the caret is in view, I’d prefer that the scroll position remain unchanged. 

When the caret is outside the view then the view is scrolled to make it visible using the normal caret policy settings.

The changes can be examined either in the repository

Neil

Mitchell

unread,
Apr 19, 2025, 11:13:08 AMApr 19
to scintilla...@googlegroups.com
Hi Neil,

> On Apr 17, 2025, at 7:55 PM, Neil Hodgson <nyama...@gmail.com> wrote:
>
> Mitchell:
> Currently, when SCI_SETUNDOSELECTIONHISTORY is enabled, undo restores both the selection and the top line (scroll) position. Can we add either an option or a bit-field to disable the latter?
>
> Yes. Added SC_UNDO_SELECTION_HISTORY_SCROLL to control whether the vertical scroll position is restored.
>
> This is an incompatible change in the sense that applications will need to set SC_UNDO_SELECTION_HISTORY_SCROLL | SC_UNDO_SELECTION_HISTORY_ENABLED to produce the previous behaviour. If this causes too much trouble for anyone, it could be replaced with a negation option ..._HISTORY_NO_SCROLL but negation flags are much less clear.
>
> > After thinking more on this, if the caret is outside the view, I’m fine restoring the scroll position. If the caret is in view, I’d prefer that the scroll position remain unchanged.
>
> When the caret is outside the view then the view is scrolled to make it visible using the normal caret policy settings.

Thank you very much! I like this change as written and will experiment with it soon.

Cheers,
Mitchell
Reply all
Reply to author
Forward
0 new messages