godot icon indicating copy to clipboard operation
godot copied to clipboard

Store line change in script navigation history

Open KoBeWi opened this issue 2 years ago • 9 comments

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. godot windows tools 64_qixu8sT8AL The implementation is rather hacky and might be not 100% reliable, but script editors are a mess :/ At least it works.

KoBeWi avatar Jul 26 '22 22:07 KoBeWi

I have the feeling I implemented this at some distant time in the past..

reduz avatar Aug 11 '22 09:08 reduz

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 avatar Aug 11 '22 10:08 Calinou

@Calinou No I am pretty sure I made the history go back to the proper script/line.

reduz avatar Aug 11 '22 10:08 reduz

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).

KoBeWi avatar Aug 11 '22 10:08 KoBeWi

Oh alright, in any case, up to @Paulb23 to review

reduz avatar Aug 11 '22 10:08 reduz

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.

KoBeWi avatar Aug 30 '22 14:08 KoBeWi

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.

Paulb23 avatar Sep 19 '22 10:09 Paulb23

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.

KoBeWi avatar Oct 22 '22 21:10 KoBeWi

I did some more tweaks and I think this works reliably now.

KoBeWi avatar Mar 22 '23 20:03 KoBeWi

Thanks!

akien-mga avatar Apr 26 '24 13:04 akien-mga