godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.94k stars 20.17k forks source link

Toggling breakpoints break when line spacing is high #93036

Open YeldhamDev opened 3 months ago

YeldhamDev commented 3 months ago

Tested versions

System information

N/A

Issue description

When hovering/clicking the breakpoint gutter in a Text/CodeEdit node that has line_spacing set to a high value, it can result in the wrong line getting the breakpoint.

CC @kitbdev.

Steps to reproduce

Minimal reproduction project (MRP)

Unnecessary, trivial to reproduce.

RadiantUwU commented 1 month ago

Looks like it might be TextEdit::get_line_column_at_pos screwing things over. I'll try to look over a fix.

RadiantUwU commented 1 month ago
int TextEdit::get_line_height() const {
    return MAX(text.get_line_height() + theme_cache.line_spacing, 1);
}

Shouldn't this account for it? Unless the theme cache for line spacing isn't being updated properly.

kitbdev commented 1 month ago

I believe the issue is because TextEdit only redraws the gutter when the hovered gutter changes, but CodeEdit uses different logic to determine which one is hovered, causing the wrong one to be hovered and then not updating when it should.

CodeEdit::_main_gutter_draw_callback uses bool hovering = p_region.has_point(get_local_mouse_pos());, while TextEdit uses get_line_column_at_pos() which isn't the same as the rect sent for the draw callback. The gutter_clicked signal also uses get_line_column_at_pos().

https://github.com/godotengine/godot/pull/92865 fixes it by exposing get_hovered_gutter() and using that in CodeEdit instead.

RadiantUwU commented 1 month ago

https://github.com/godotengine/godot/pull/92865 fixes it by exposing get_hovered_gutter() and using that in CodeEdit instead.

Is the bug no longer reproducible in #92865 ?

kitbdev commented 1 month ago

Is the bug no longer reproducible in https://github.com/godotengine/godot/pull/92865 ?

Yes, I cannot reproduce it in #92865.