Skip to content

Conversation

WhalesState
Copy link
Contributor

@WhalesState WhalesState commented Jul 29, 2025

This PR refactors TextEdit to stop clipping its children and now uses its own CanvasItem logic for drawing text.

Changes:

  • TextEdit no longer clips child nodes.
  • Custom CI-based drawing is used for rendering text in TextEdit.
  • Custom CI-based drawing is used for rendering code completion in CodeEdit.

Note: This PR is not intended to change any existing behavior due to the complexity of the TextEdit class. The only goal is to resolve the mentioned issues and improve internal drawing consistency.

@WhalesState WhalesState requested review from a team as code owners July 29, 2025 13:07
@WhalesState WhalesState changed the title Fix TextEdit styles and disable clipping. Improve TextEdit Rendering and Focus Styling in Script Editor. Jul 29, 2025
@KoBeWi KoBeWi added this to the 4.x milestone Jul 29, 2025
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.

I don't know much about the rendering server methods to add canvas items, but it seems to work fine.

Some minor issues:

CodeEdit::_draw_guidelines still uses theme_cache.style_normal.

TextEdit::set_editable should call update_minimum_size().

@WhalesState WhalesState requested a review from a team as a code owner August 14, 2025 04:25
@WhalesState WhalesState force-pushed the text-edit-clipping branch 2 times, most recently from 8303df9 to 31485d3 Compare August 14, 2025 06:29
@WhalesState WhalesState marked this pull request as draft August 14, 2025 07:21
@WhalesState WhalesState marked this pull request as ready for review August 14, 2025 09:11
@WhalesState
Copy link
Contributor Author

WhalesState commented Aug 16, 2025

This sounds kind of like #79735 but offset the other way.

The half line spacing we add to offset the text should be removed or double checked if it's taken into account in all other calculations like _get_visible_lines_offset and get_visible_line_count.

@WhalesState WhalesState force-pushed the text-edit-clipping branch 2 times, most recently from c140ed7 to f12a8bd Compare August 17, 2025 16:33
@WhalesState WhalesState marked this pull request as draft September 15, 2025 07:25
@WhalesState
Copy link
Contributor Author

WhalesState commented Sep 15, 2025

Moved the styles fix to another PR #110527, will keep this PR fixing only the clipping issues.

@WhalesState WhalesState force-pushed the text-edit-clipping branch 2 times, most recently from 0af4e9d to 2e9f911 Compare September 15, 2025 08:49
@WhalesState WhalesState changed the title Improve TextEdit Rendering and Focus Styling in Script Editor. Fix TextEdit clips children and focus style. Sep 15, 2025
@WhalesState WhalesState marked this pull request as ready for review September 15, 2025 08:53
@kitbdev
Copy link
Contributor

kitbdev commented Sep 15, 2025

The half line spacing we add to offset the text should be removed or double checked if it's taken into account in all other calculations like _get_visible_lines_offset and get_visible_line_count.

I think it will have to be considered there. I've been looking for some inconsistency with related calculations, so thanks for pointing that out. This can be done later though, the behavior in #110527 get_line_column_at_pos is good for now. It can be more easily seen with the cross cursor.

@kitbdev kitbdev added the bug label Sep 15, 2025
@kitbdev kitbdev modified the milestones: 4.x, 4.6 Sep 15, 2025
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.

Looks good.

  • This also fixes #74445 since the expand margins now work by default .
  • I don't think this fixes #42342 I think it is talking about how the text doesn't get clipped accurately when there is a content margin on a per pixel bases, though it is hard to tell.

Note that TextEdit's clip_contents default value changed, but this is needed to fix the issues.

@Repiteo Repiteo merged commit 5db618a into godotengine:master Sep 24, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Sep 24, 2025

Thanks!

@WhalesState WhalesState deleted the text-edit-clipping branch September 24, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants