Skip to content

Conversation

@timothyqiu
Copy link
Member

The problem: When editing scripts, I often notice this kind of jump caused by line numbers.

Peek 2025-10-28 16-56

This PR:

  • Adds a line_numbers_min_digits property to CodeEdit. It defaults to 1 to be compatible with existing projects.
  • Adds an editor setting text_editor/appearance/gutters/line_numbers_min_digits which defaults to 2.

@Mickeon
Copy link
Member

Mickeon commented Oct 28, 2025

For reference, and from what I can see, in terms of what other programs do:

  • Visual Studio Code has a minimum width of 4. This cannot be customized.
  • Notepad++ has a minimum width of 3 if the "Line Number" is set to "Dynamic width", otherwise it's 4.
  • Github's online text editor has no minimum width.

Given that some scripts can genuinely be really brief and self-sustaining, a minimum width of 2 by default in this PR may sound ideal. However, I would say that for any practical purposes most scripts will easily reach 3 digits, so that would be more ideal in my opinion.

I also would not make this an editor setting, personally, unless there's severe demand for it, because it's far too niche. A property or theme item may be fine, however.
Even if you disagree, the current range (up to 10 or even greater) is absolutely ridiculous for many reasons, but let's also keep in mind that the existing text editor already struggles with horizontal space, which makes the need to increase this number even more unlikely.

@AThousandShips AThousandShips added this to the 4.x milestone Oct 28, 2025
@timothyqiu timothyqiu force-pushed the line-number-min-chars branch from fe7ac97 to 7031bab Compare October 28, 2025 13:35
@timothyqiu
Copy link
Member Author

  • Changed the range hint to 1,5,1.
  • Changed the editor setting's default to 3.

I also would not make this an editor setting, personally, unless there's severe demand for it, because it's far too niche. A property or theme item may be fine, however.

There may be some misunderstanding here. This PR adds a property to the CodeEdit node. The CodeTextEditor in the editor uses CodeEdit and applies the editor setting to it.

@Mickeon
Copy link
Member

Mickeon commented Oct 28, 2025

No misunderstanding. I am aware of what this PR does. I just think an editor setting is excessive.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected. I think this is a good usability improvement, not only when editing code, but also when switching between scripts.

That said, in complex projects, the majority of GDScript files are expected to be in the 100-999 line range. Therefore, I don't think we need to expose an editor setting for this. A lower value would save a tiny bit of horizontal space in projects that use lots of small scripts, but you'd reintroduce the issue with layout shifts on script change as soon as you even have one script with 100+ lines of code.

Copy link
Member

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am neutral on the actual property itself. I think it makes sense, but I've never seen it being suggested until now. I approve for the editor's usability.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants