Open yankscally opened 9 months ago
Looks like the returned x-position is the same for column 0 and 1 for some reason, other columns seem to work okay. A little easier EditorScript (right mouse button -> Run) for testing:
@tool
extends EditorScript
func _run():
var code_edit_node = get_editor_interface().get_script_editor().get_current_editor().get_base_editor()
var line = code_edit_node.get_caret_line(0)
var column = code_edit_node.get_caret_column(0)
var caret_pos = code_edit_node.get_pos_at_line_column(line,column)
print(line + 1, ", ", column, ", ", caret_pos)
The col_bounds
in get_rect_at_line_column
is the same for column 0 and 1 :
RID text_rid = text.get_line_data(p_line)->get_line_rid(wrap_index);
Vector2 col_bounds = TS->shaped_text_get_grapheme_bounds(text_rid, p_column);
pos.x += col_bounds.x;
size.x = col_bounds.y - col_bounds.x;
Godot version
4.1.1
System information
Windows 10
Issue description
using a tool script (not sure if this makes any difference) and using the code edit node from the editor script editor,
get_pos_at_line_column(line,col) giving incorrect Vector2 if column = 1
Steps to reproduce
do that
Minimal reproduction project
n/a