Bug 153798 - Line numbers should be aligned to the right in the Basic IDE
Summary: Line numbers should be aligned to the right in the Basic IDE
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: All All
: medium enhancement
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.6.0
Keywords:
Depends on:
Blocks: BASIC-IDE
  Show dependency treegraph
 
Reported: 2023-02-24 12:04 UTC by Rafael Lima
Modified: 2023-02-28 11:14 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot showing the problem (134.91 KB, image/png)
2023-02-24 12:04 UTC, Rafael Lima
Details
PyCharm line numbering (16.39 KB, image/png)
2023-02-24 17:07 UTC, Roman Kuznetsov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2023-02-24 12:04:30 UTC
Created attachment 185563 [details]
Screenshot showing the problem

Full disclosure: this is a nitpick.

In all code editors/IDEs I use (PyCharm, VSCode and Kate), line numbers in the code editor are aligned to the right. I also noticed that this is the case in various other code editors (Gedit, Sublime, etc).

However, Basic IDE aligns numbers to the left (see attached screenshot comparing Basic IDE and Kate). When the code module gets to the hundreds or thousands of lines, then it looks weird to have left-aligned numbers.

I believe we should align them to the right as other code editors do.
Comment 1 Julien Nabet 2023-02-24 15:58:17 UTC
Notepad++ and Vim use line numbers at left (at least with English/French UI, I don't know for RTL UI), I find it fine.

Perhaps there should be some config option for this?
Of course, there would still be the pb of which side by default.
Comment 2 Roman Kuznetsov 2023-02-24 17:07:25 UTC
(In reply to Julien Nabet from comment #1)
> Notepad++ and Vim use line numbers at left (at least with English/French UI,
> I don't know for RTL UI), I find it fine.
> 
> Perhaps there should be some config option for this?
> Of course, there would still be the pb of which side by default.

Basic IDE has
1
2
...
9
10
11
12
etc

PyCharm

 1
 2
 ...
 9
10
11
12
etc

But there is some space to right from numbers in PyCharm anyway

I don't think it's so much matter, btw
Comment 3 Roman Kuznetsov 2023-02-24 17:07:46 UTC
Created attachment 185576 [details]
PyCharm line numbering
Comment 4 Rafael Lima 2023-02-24 17:16:52 UTC
(In reply to Roman Kuznetsov from comment #2)
> I don't think it's so much matter, btw

Indeed it's not a very significant issue. It's more about aesthetics, which is subjective.

The right alignment might be a better choice when code folding is implemented (see bug 146667). The folding symbol would always be the same distance from the line number if the numbers are aligned to the right.

(In reply to Julien Nabet from comment #1)
> Notepad++ and Vim use line numbers at left (at least with English/French UI,
> I don't know for RTL UI), I find it fine.

As far as I remember, Notepad++ aligns to the right as well. I no longer use it, but the screenshots I found online align line numbers to the right. See:

https://static.techspot.com/images2/downloads/bigimage/2019/2019-06-03-image-p_1100.webp
Comment 5 Julien Nabet 2023-02-24 17:54:36 UTC
(In reply to Roman Kuznetsov from comment #2)
> (In reply to Julien Nabet from comment #1)
...
> But there is some space to right from numbers in PyCharm anyway
> 
> I don't think it's so much matter, btw

Very sorry, I misinterpreted what you said, I thought the line number was on the right of the code for these IDEs.
Forget my previous comment then.
Comment 6 Andreas Heinisch 2023-02-25 06:16:54 UTC
Imho, valid enhancement. How should we treat them in the RTL mode?
Comment 7 Heiko Tietze 2023-02-27 09:09:18 UTC
(In reply to Andreas Heinisch from comment #6)
> Imho, valid enhancement. How should we treat them in the RTL mode?

+1, regarding RTL I think the number frame will be on the right but since numbers are left-oriented I think right-aligning makes sense. Eyal, what do you think?

Fun-fact: starting the app with SAL_RTL_ENABLED=1 shows the number frame right hand with numbers right-aligned.
Comment 8 Eyal Rozenberg 2023-02-27 09:48:28 UTC
Well, things are kind of complicated. 

First there's the question of whether numbers should be on the right in the first place - seeing how the Basic _code_ is not RTL and not right-aligned. In fact, I'd probably say the line numbers should be to the left of the code - otherwise they're very far from the code, which is bad. Another option is placing line numbers on _both_ sides.

About alignment of the numbers within their column - I'd say this depends on the number representation system of each written language. If the digit position corresponds to a power of 10, with highest-powers on the left (which is the case for all of English, Hebrew, Arabic - but perhaps not for all languages) - then right-aligning makes sense. Otherwise - depending on the specifics of the language.
Comment 9 Heiko Tietze 2023-02-27 11:07:36 UTC
(In reply to Eyal Rozenberg from comment #8)
> Basic _code_ is not RTL and not right-aligned...
Good point. Maybe worth another ticket / patch.

> About alignment of the numbers within their column - I'd say this depends on
> the number representation system of each written language.
Okay, so let's have it always right-aligned, as requested.
Comment 10 Rafael Lima 2023-02-27 11:40:52 UTC
(In reply to Eyal Rozenberg from comment #8)
> First there's the question of whether numbers should be on the right in the
> first place - seeing how the Basic _code_ is not RTL and not right-aligned.
> In fact, I'd probably say the line numbers should be to the left of the code
> - otherwise they're very far from the code, which is bad.

Just to be clear, what I'm proposing is to leave the line numbers to the left of the code, but they'll be right-aligned inside the box where line numbers are displayed.
Comment 11 Eyal Rozenberg 2023-02-27 11:46:44 UTC
(In reply to Rafael Lima from comment #10)
> Just to be clear, what I'm proposing is to leave the line numbers to the
> left of the code, but they'll be right-aligned inside the box where line
> numbers are displayed.

I understand, I was opining about the more general question, not just the alignment, and I realize that's beyond the scope of this bug.
Comment 12 Eyal Rozenberg 2023-02-27 11:51:45 UTC
(In reply to Heiko Tietze from comment #9)
> Good point. Maybe worth another ticket / patch.

Filed bug 153853.

> Okay, so let's have it always right-aligned, as requested.

Are you sure we don't support languages which lay their numbers differently?
Comment 13 Commit Notification 2023-02-28 07:16:02 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/dbd96e1c9a066979cb80ced6268edb148a8fc73b

tdf#153798 - Basic IDE: align line numbers to the right

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Rafael Lima 2023-02-28 11:14:22 UTC
Thanks Andreas, it's working perfectly!