Skip to content

Commit

Permalink
Fix BetterTextEdit caret misplacement (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
MewPurPur authored Aug 19, 2024
1 parent e91f9e3 commit 14711fc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1,001 deletions.
5 changes: 3 additions & 2 deletions src/ui_widgets/BetterTextEdit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func _ready() -> void:
add_child(_timer)
_timer.timeout.connect(blink)
get_v_scroll_bar().value_changed.connect(queue_redraw_caret.unbind(1))
resized.connect(queue_redraw_caret.unbind(1), CONNECT_DEFERRED)
get_h_scroll_bar().value_changed.connect(queue_redraw_caret.unbind(1))
mouse_exited.connect(_on_base_class_mouse_exited)
focus_entered.connect(_on_base_class_focus_entered)
Expand Down Expand Up @@ -62,8 +63,8 @@ func redraw_caret() -> void:
var caret_line := get_caret_line(caret)

if caret_column == 0:
caret_pos = Vector2(get_theme_stylebox("normal").content_margin_left + 1,
get_line_height() * (caret_line + 1) + 1)
caret_pos = Vector2(get_theme_stylebox("normal").content_margin_left,
get_rect_at_line_column(caret_line, caret_column).end.y) + Vector2(1, -2)
else:
var glyph_end := Vector2(get_rect_at_line_column(caret_line, caret_column).end)
caret_pos = glyph_end + Vector2(1, -2)
Expand Down
Loading

0 comments on commit 14711fc

Please sign in to comment.