Bug 145764 - Pressing "Home" key in Basic IDE should move cursor to first character in the same line
Summary: Pressing "Home" key in Basic IDE should move cursor to first character in the...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.3.0.0.alpha1+
Hardware: All All
: medium enhancement
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.4.0
Keywords:
Depends on:
Blocks: BASIC-IDE
  Show dependency treegraph
 
Reported: 2021-11-18 18:09 UTC by Rafael Lima
Modified: 2021-12-13 07:16 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshots illustrating the proposal (59.82 KB, application/vnd.oasis.opendocument.graphics)
2021-11-18 18:09 UTC, Rafael Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2021-11-18 18:09:33 UTC
Created attachment 176348 [details]
Screenshots illustrating the proposal

Nowadays, text editors and IDEs have a common behavior: if you're editing a line of code and press "Home", the cursor will move to the first character in the same line that is not a blank space or Tab.

However, on LO Basic IDE, pressing Home will move the cursor to position 1 in the same line regardless of its contents and indentation.

So I would like to suggest to implement this behavior in Basic IDE, so that when "Home" is pressed, the cursor would be placed in the first non-blank character (see attached ODG file for a better explanation).
Comment 1 Roman Kuznetsov 2021-11-18 19:18:31 UTC
Andreas, Alain, what do you think?
Comment 2 Andreas Heinisch 2021-11-18 20:53:19 UTC
+1 from my side. I would implement it as all the other IDEs:

"Home" key pressed and not being on position 1:
move cursor to the non whitespace character in the corresponding line

"Home" key pressed and cursor being at first non whitespace character:
move the cursor to position 1
Comment 3 Heiko Tietze 2021-11-25 10:00:24 UTC
Yes, the second Home (or pressing at line start) goes to the very beginning of the line.
Comment 4 Commit Notification 2021-12-11 15:58:33 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/809236ed826b67328409e008313dea87de6d5243

tdf#145764 - BASIC IDE Home Key: move cursor to the beginning/first character

It will be available in 7.4.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 5 Andreas Heinisch 2021-12-11 16:02:28 UTC
I hope this patch completes this enhancement request. Maybe there are some corner cases where the BreakIterator.nextWord method misses a whitespace. Additional testing is appreciated.
Comment 6 Adolfo Jayme Barrientos 2021-12-11 16:10:21 UTC
Danke, Andreas! Loving all the little quality-of-life improvements you’re making.
Comment 7 Andreas Heinisch 2021-12-11 21:26:14 UTC
You are welcome πŸ˜€ So many bugs I wish I could tackle, but so less time 😞
Comment 8 Andreas Heinisch 2021-12-12 10:10:42 UTC
Have to reopen the enhancement request since I did not fully understand how the feature should work. As Mike pointed out in [1] pressing the home key should only move to position one if the current position is at the first word.

[1] https://gerrit.libreoffice.org/c/core/+/126548/comment/64052f6b_20f2f987/
Comment 9 Rafael Lima 2021-12-13 00:21:35 UTC
Andreas, thank you for implementing this new feature. It'll be very useful for everyone using the Basic IDE.

As for what Mike suggested, this is something I had never noticed in IDEs; but I tested it this is the way it works in Kate (and some other IDEs).

But in other popular IDEs as PyCharm, pressing the "Home" key will take the cursor to the first position in the line instead of taking it to the first word (as is done by the current fix implemented by Andreas).

If if turns out to be too hard to implement Mike's suggestion, I believe the current implementation will suffice for most use cases.
Comment 10 Andreas Heinisch 2021-12-13 06:14:53 UTC
I implemented both cases now, so we can decide:
https://gerrit.libreoffice.org/c/core/+/126702

Waiting for a comment from Mike if he thinks it fits the needs now.
Comment 11 Commit Notification 2021-12-13 06:54:45 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1aa0a43d60336eb1f0e51805939a7cc00b377a2b

tdf#145764 - Change behaviour of BASIC IDE Home Key

It will be available in 7.4.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 12 Mike Kaganski 2021-12-13 07:16:25 UTC
(In reply to Rafael Lima from comment #9)
> But in other popular IDEs as PyCharm, pressing the "Home" key will take the
> cursor to the first position in the line instead of taking it to the first
> word (as is done by the current fix implemented by Andreas).

This is not correct. E.g., PyCharm (as tested with 2021.3 Community Edition) uses a slight modification of what I suggested, but not what was implemented before comment 11: it goes to the first "word" *unless the cursor is to the left of it* (i.e., it goes to the left when it's in the middle of the whitespace before the first non-whitespace character - but it will go to the first non-whitespace character from any other character to the right).

Andreas made a brilliant job, and it now works as I suggested. Thanks! (Wrt PyCharm-like modification: if someone would like to implement *that*, I'd consider that nitpicking, but have nothing against that, as long as it's consistent and does not introduce new settings for such a tiny differences - either current behavior, or the other, but not both please ;))