Skip to content

CodeEditor: Make possible to select and copy error text #77776

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

Merged

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Jun 2, 2023



  • Replace Label with RichTextLabel, enable selection and context menu.
    • This also removes horizontal scrolling.
  • Replace unnecessary includes with forward declaration.
  • Remove unnecessary overrides in _update_text_editor_theme().

@dalexeev dalexeev requested a review from a team as a code owner June 2, 2023 17:26
@MewPurPur
Copy link
Contributor

Very cool, but the reduction of space is concerning me. In this case maybe it's okay, as there won't be another useful thing to add there, but the error preview is becoming too small and I wonder if we can do anything about it.

@dalexeev
Copy link
Member Author

dalexeev commented Jun 3, 2023

We could make the button appear only when hovering over the bottom bar. Or alternatively replace the Label with RichTextLabel and enable text selection.

@Calinou
Copy link
Member

Calinou commented Jun 5, 2023

  • Remove scrolling. Display ellipsis and tooltip instead.

Unfortunately, this is not friendly to touch inputs (for the Android editor).

We could make the button appear only when hovering over the bottom bar. Or alternatively replace the Label with RichTextLabel and enable text selection.

This would be my preferred alternative, so we can use rich formatting in the long run. This way, we can use a proportional font for the error message and use the code font for text between backticks.

@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch from 123b19d to 56a595e Compare June 5, 2023 16:58
@dalexeev dalexeev changed the title CodeEditor: Add copy error button CodeEditor: Make possible to select and copy error text Jun 5, 2023
@dalexeev
Copy link
Member Author

dalexeev commented Jun 5, 2023

Yes, I like it better too. The copy button is more obvious, but I think users will figure it out. Horizontal scrolling can be removed without clipping the text. I have updated the PR and the first post.

@Calinou
Copy link
Member

Calinou commented Jun 5, 2023

Could a similar change be made to the error text displayed when hitting a breakpoint, script error or assertion? It's currently not selectable, although there is a button to copy it on the right edge (not easy to see on a 4K monitor at 100% scaling).

image

@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch from 56a595e to 3af5db4 Compare June 5, 2023 19:10
@dalexeev dalexeev requested a review from a team as a code owner June 5, 2023 19:10
@dalexeev
Copy link
Member Author

dalexeev commented Jun 5, 2023

For some reason Select All doesn't work. But in the Output Log it works.

Looks like it's a RichTextLabel bug, Select All doesn't work if there are no line breaks.

assert(false, "Doesn't work.")
assert(false, "It works.\n")

@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch from 3af5db4 to 9622b4f Compare September 11, 2023 09:30
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on Linux (rebased on top of master f5696c3). In the script, shader editors, and debugger stack trace panel:

  • The Select All action works correctly (and you can press Ctrl + C afterwards to copy).
  • The Copy action does nothing even if I try it several times.

@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch 2 times, most recently from 60a7e12 to 559ef9f Compare March 14, 2024 17:59
@dalexeev
Copy link
Member Author

This is especially useful after #82952:

@akien-mga akien-mga requested a review from Calinou March 14, 2024 18:07
@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch 2 times, most recently from b6b8f92 to 7fbb8b6 Compare April 22, 2024 08:37
@dalexeev dalexeev marked this pull request as draft February 16, 2025 19:42
@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch from 7fbb8b6 to 377a309 Compare May 6, 2025 21:16
@dalexeev dalexeev marked this pull request as ready for review May 6, 2025 21:17
@dalexeev dalexeev requested a review from a team as a code owner May 6, 2025 21:17
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, there's an issue if you resize the editor window to be narrow:

image

It's better at slightly wider widths:

image

I would probably make it so it can't wrap over more than 3 lines.

Also, right-clicking the error message and choosing Copy has no effect if no text is selected. (This is why I had the impression the option had no effect for the longest time.) This is an issue with the RichTextLabel context menu, so we should look into addressing it in a separate PR.

Overall, I agree with the decision to use RichTextLabel as it'll allow to use rich formatting in the future (e.g. use a code font for text between backticks, and a regular font otherwise).

@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch from 377a309 to c25f40e Compare May 13, 2025 05:25
@dalexeev
Copy link
Member Author

I would probably make it so it can't wrap over more than 3 lines.

Done.


@dalexeev dalexeev force-pushed the code-editor-copy-error-button branch from c25f40e to 51ebcdc Compare May 13, 2025 16:43
Copy link
Contributor

@kitbdev kitbdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected.

@akien-mga akien-mga force-pushed the code-editor-copy-error-button branch from 51ebcdc to db9b8ff Compare June 12, 2025 20:27
@akien-mga akien-mga merged commit f9475a8 into godotengine:master Jun 12, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@dalexeev dalexeev deleted the code-editor-copy-error-button branch June 13, 2025 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve readability of GDScript errors Add an ability to copy code hints in errors
6 participants