godot
godot copied to clipboard
Store line change in script navigation history
Closes #16554 Closes https://github.com/godotengine/godot-proposals/issues/4989 (what a coincidence...)
Any movement with more than 10 lines apart is saved into history.
The implementation is rather hacky and might be not 100% reliable, but script editors are a mess :/ At least it works.
I have the feeling I implemented this at some distant time in the past..
I have the feeling I implemented this at some distant time in the past..
You might be thinking about script tab temperature, which is a different feature that serves different needs.
@Calinou No I am pretty sure I made the history go back to the proper script/line.
Yes, the history works this way, but the line change wasn't recorded in the history. Only script changes were and in 3.x Ctrl+clicks on members (which was probably a convenient bug lol).
Oh alright, in any case, up to @Paulb23 to review
Should also probably add support for scrolling around the docs as well.
Docs don't have caret though.
EDIT: Soooo
Yep definitely a slightly hacky approach, using [set|get]_edit_state will also change breakpoints and bookmarks etc, so currently we could end up resting these as well, which is not ideal.
I was testing this and yes, my deleted bookmarks get restored when I go back. I just hooked into already-existing script history, which unfortunately keeps everything for whatever reason. I think we should have something like "navigation state" that stores only caret position and scrolls. It would be a subset of the full state and used by the history. Then full state would be tied only to the script editors.
For docs I was thinking along the lines of, clicking some in doc navigation such as a method in the same class. It would be nice to store that as a navigation action, would be v_scroll
here rather the caret.
Updated. I changed to use the new navigation history and simplified storing a bit. Also I added some scroll saving to editor help, but it's unreliable.
There is a bug sometimes where a position can be saved twice in a history, but I don't know what triggers it.
I did some more tweaks and I think this works reliably now.
Thanks!