Your mental model is incorrect, so your expectation is incorrect.
You may see a change in the width of the edit pane due to hiding of the sidebar, and then an undo of that change, but Geany and Scintilla only see a sequence of two unrelated changes, not an undo.
The fact that the the resultant width happens to be the same as the prior one is irrelevant, no record of previous widths or scroll positions is kept, so there is no way for Geany/Scintilla to detect it, nor of undoing it since there is no record of scroll positions to undo.
So if one operation causes scrolling, the other won't undo it, to maintain manual scroll positions nothing is scrolled unless some other rule (like not allowing blank space below the last line) requires it. Otherwise when the user scrolled away from the cursor position the display would not stay there.
so your expectation is incorrect.
You should not let your understanding and expectation be confused with what you __prefer__ to happen, thats something totally different :grin:.
As you said, changing it to behave as you prefer requires some way of implementing that change to be identified, and then if other users agree with the new behaviour the PR can be added (no reason they should not if nothing other than this edge case changes, I doubt anyone will be critically depending on such edge case behaviour, but if it results in changes of behaviour elsewhere there may be more robust discussions).