Currently the markdown preview always resets the scroll position of the preview on any modification of the markdown text.
I would be nice if the preview can remember the scroll position.
I tried to fix this in d1a4dd15089551cd2eddcf9beb77ee9256f2d26f and I thought I remember @b4n helping with this too, but I can't seem to find that discussion.
Same scroll position bug here with geany 1.37.1 and geany plugins 1.37 compiled from sourcecode under Debian GNU/Linux 10 (buster)
Not sure what version on windows at the moment (at the company) but it works well
@Sci-Mon do you mind reporting back with the version on Windows whenever you're next on that computer? I swear this was fixed, but maybe it got broken somehow in the intervening versions.
Hi again
I'm at the company now. It is geany 1.34.1 that is working fine...
Cant post it directly on github yet because I don't remember the pwd :(
Best regards
Simon
Am 2021-02-05 02:26, schrieb Matthew Brush:
@Sci-Mon [1] do you mind reporting back with the version on Windows whenever you're next on that computer? I swear this was fixed, but maybe it got broken somehow in the intervening versions.
-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [2], or unsubscribe [3].
Links:
[1] https://github.com/Sci-Mon [2] https://github.com/geany/geany-plugins/issues/1055#issuecomment-773716894 [3] https://github.com/notifications/unsubscribe-auth/ASXNL5HE7LEYG7IICJPIQULS5N...
After a little bit of reading/experimenting, I think this is probably caused by the Webkit2 no longer requiring a GtkScrolledWindow and handling scrolling on its own in a separate process. Whenever the existing scrollbar adjustments are read, the value is always zero, so the hack that was previously added for the old Webkit version no longer works.
A possible workaround might be to run some javascript in the webview that can read the scroll position and pass it back up to the plugin's C code so it's able to save and then other JS to restore it.
Oh wow, thanks for the 'investigations' about that bug. I think I understand the problem here although I only do a bit programming in C/gcbasic for 8051/arduino microcontrollers and TCL/TK by myself **;-)**
I can imagine that if it's possible to run JS in the webview, this would be a workaround. But hey, if it's too time consuming for you, I fully understand. Geany is already a cool tool for coding a bit and write some markdown-text.
After a little more research I think it might be possible to do it fully within JS by loading the scroll position from the browser's localStorage (or maybe just sessionStorage) when the DOM is finished loading and saving it before the page is unloaded. If I can get that working, it should do the trick for both Webkit1 and Webkit2 and allow to remove some code from the plugin.
Basic theoretical untested code:
```js document.addEventListener('DOMContentLoaded', () => { const pos = localStorage.getItem('mdScrollPos'); if (pos) window.scrollTo(pos.x, pos.y); }); window.onbeforeunload = () => { localStorage.setItem('mdScrollPos', { x: window.scrollX, y: window.scrollY, }); }; ```
To make it have different scroll positions saved per file rather than one global scroll position for all files will require to pass the filename through the template to JS so it can keep track of which scroll position to load/save. It might also require a bit of JS code to prune/vacuum the localStorage to get rid of scroll positions older than a certain date and/or above a certain number, but that might be overkill.
Next time I'm working on the plugin I'll try and see if it works.
I just wanted to ask if you could make any progress in this topic... (sorry if I am too impatient)
I have not. I'll update here if I do. If anyone wants to work on it, ping me if you need any assistance.
@codebrainz I've opened a pull request #1111 to address this issue.
Issue still present and relevant in 1.38, running at ubuntu 22.04.
The maintainer of the markdown plugin has not been heard from for several years, so the plugin should probably be considered orphaned.
github-comments@lists.geany.org