-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Do not bother with line colors if line_number_gutter
is not yet calculated
#84907
Conversation
line_number_gutter
is not yet calculated
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.
Thanks for the detailed description!
Looks like the root cause is the editor lazy loading, as you pointed out. Once the tab is loaded _validate_script
is connected / called. So we should probably not call it in the first place if the editor is not enabled, as there might be other things in an unexpected state. Would guess it's called from reload_text
.
I cannot reproduce the bug with v4.3.dev2.official either. Edit: Yes, I can reproduce the bug after all. |
@@ -662,6 +662,10 @@ void ScriptTextEditor::_update_errors() { | |||
errors_panel->pop(); // Indent. | |||
} | |||
|
|||
if (line_number_gutter == -1) { |
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.
It might be worth adding a comment to describe why this early return is here.
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.
The fix changed completely. The current fix is a bit more self explanatory.
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 tried the solution suggested by Paulb23 and it seems to work, so I changed what this fix does. Now |
Thanks! |
Cherry-picked for 4.2.2. |
Fixes #81135
When code files are changed with an external editor, all files in script list are reloaded. Files are validated and then
_update_errors()
is called for each file and type safe lines are colored by_update_errors()
callingTextEdit
'sset_line_gutter_item_color()
withline_number_gutter
as a parameter.line_number_gutter
is however calculated only when a file is opened to the edit view. When a project is opened, only one file is opened to edit view and only that file'sline_number_gutter
is calculated. If any file is now saved in external editor, all other files haveline_number_gutter == -1
and the error message "Index p_gutter = -1 is out of bounds" is spawned for every line of those files. If the user opens all files in script list to the edit view before saving in the external editor, every file will have it'sline_number_gutter
calculated and there will be no errors.This is now fixed simply by skipping the setting of line colors altogether if theline_number_gutter
is not yet calculated. The script is not shown, so it doesn't matter. When the user opens the script file to the edit view,line_number_gutter
is calculated and also_update_errors()
is called again.This is now fixed by not calling
_validate_script()
fromreload_text()
ifeditor_enabled == false
.