Skip to content
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

TextEdit set_line_gutter_icon does not show an icon in projects #88859

Closed
aaronfranke opened this issue Feb 26, 2024 · 3 comments · Fixed by #88875
Closed

TextEdit set_line_gutter_icon does not show an icon in projects #88859

aaronfranke opened this issue Feb 26, 2024 · 3 comments · Fixed by #88875

Comments

@aaronfranke
Copy link
Member

Tested versions

Latest master as of writing, 4.3-dev 99addd6

System information

macOS 14.2.1, Apple M1 Pro

Issue description

In TextEdit, set_line_gutter_icon does not show an icon when used in projects. However, the similar set_line_gutter_text function does show text, so this is evidence that my gutters are set up correctly.

However, the strange part is that set_line_gutter_icon is working when called from the editor for use with the script editor's gutter icons, but it does not work when called from user script in a project.

Steps to reproduce

Download and run the minimal reproduction project, which contains this code:

func _ready() -> void:
	add_gutter(0)
	set_gutter_width(0, get_line_height())
	set_line_gutter_icon(1, 0, preload("res://icon.svg"))
	set_line_gutter_text(2, 0, "hi")

This script adds a gutter, sets an icon for line index 1 (line 2), and sets text for line index 2 (line 3).

Expected behavior: The icon is displayed in the gutter, on the second line, to the left of the letter b.

Observed behavior: No icon is displayed in the gutter.

Screenshot 2024-02-26 at 4 05 56 AM

Minimal reproduction project (MRP)

TextEditIconBroken.zip

@aaronfranke
Copy link
Member Author

Also, a related bug, it seems that gutter custom draw callbacks are not being run at all:

func _ready() -> void:
	add_gutter(0)
	set_gutter_custom_draw(0, draw_gutter)
	set_gutter_width(0, get_line_height())


func draw_gutter(line: int, gutter: int, area: Rect2) -> void:
	print("draw_gutter")

Expected behavior: It prints draw_gutter sometimes.

Observed behavior: Nothing is ever printed.

@AeioMuch
Copy link
Contributor

AeioMuch commented Feb 26, 2024

Also, a related bug, it seems that gutter custom draw callbacks are not being run at all:

func _ready() -> void:
	add_gutter(0)
	set_gutter_custom_draw(0, draw_gutter)
	set_gutter_width(0, get_line_height())


func draw_gutter(line: int, gutter: int, area: Rect2) -> void:
	print("draw_gutter")

Expected behavior: It prints draw_gutter sometimes.

Observed behavior: Nothing is ever printed.

It works if you add this line set_gutter_type(0, TextEdit.GUTTER_TYPE_CUSTOM)
Same for the icon you need to do set_gutter_type(0, TextEdit.GUTTER_TYPE_ICON)

I imagine that the custom is for when you want to handle both strings and icons at the same time ?

@aaronfranke
Copy link
Member Author

Thank you @AeioMuch that was it. I opened PR #88875 to document this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants