-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store line change in script navigation history #63515
Conversation
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Should also probably add support for scrolling around the docs as well.
void ScriptTextEditor::_on_caret_moved() { | ||
int current_line = code_editor->get_text_editor()->get_caret_line(); | ||
if (ABS(current_line - previous_line) > 10) { | ||
emit_signal(SNAME("request_save_previous_state"), previous_line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we emit the variant
here, then we don't have to expose it to ScriptEditorPlugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is a way to use a signal without exposing it, is there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean't not exposing the [get|set]_previous_state
methods by emitting the state directly here (only navigation state).
Docs don't have caret though. EDIT:
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 |
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. |
a4bda9d
to
e037705
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, seems to work fine.
Thanks! |
Closes #16554
Closes godotengine/godot-proposals#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.