godotengine / godotengine/godot

ItemList text threshold for truncating with ellispis (...) may need changing

Open
#97,125 1 comment 0 reactions 0 assignees View on GitHub
bug topic:gui
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

4.3

### System information

Windows 10

### Issue description

In an ItemList, names are truncated if they are too wide for the list. Usually this is done with an ellipsis `...`, but when the width is small enough, no ellipsis is used, so more of the original name is preserved. This is good behavior, otherwise a label like `new_script.gd`, truncated to 5 characters, would appear as `ne...` rather than `new_s`.

There is some threshold for when truncation stops using ellipses. **Possibly this threshold should be changed, so that ellipsis truncation is used for more narrow controls than it currently is.**

The exact logic may also need tweaking. In this example, the list item named `wwwwwwwwwwwwww` is truncated without an ellipsis, even though visually it has room for an ellipsis.

Observed behavior in the MRP:

https://github.com/user-attachments/assets/74bc973d-7544-4236-97bb-af7895c3864b

**Context:**
I first noticed this behavior when testing https://github.com/godotengine/godot/pull/96909. That PR changed the minimum width of the script list to 100, and now the width is small enough that many script names are truncated with no ellipsis.

Observed behavior in the https://github.com/godotengine/godot/pull/96909 artifact. Not how `new_script.cs` file is truncated without ellipsis.

https://github.com/user-attachments/assets/de277fb5-d98e-4320-a506-41a2ff36f1ad

### Steps to reproduce

Open the MRP.
Adjust the HSplitContainer left and right. You can test with and without 16x16 icons.
Observe that at a certain width, some labels are truncated using an ellipsis and some are not.

### Minimal reproduction project (MRP)

[mrp-truncation.zip](https://github.com/user-attachments/files/17033343/mrp-truncation.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached minimal reproduction project and reproduce the ItemList behavior while adjusting the HSplitContainer width, with and without 16x16 icons. Compare the truncation threshold for names such as `new_script.gd` and `wwwwwwwwwwwwww`; the issue does not specify an agreed threshold or target behavior, so the desired result needs clarification before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.