Bug 160202 - EDITING keyboard selection in Basic editor: selection extended one position too far (e.g. Ctrl+Right selects _two_ strings in stead of one)
Summary: EDITING keyboard selection in Basic editor: selection extended one position t...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:25.2.0 target:24.8.3
Keywords: bibisected, bisected, regression
Depends on:
Blocks: BASIC-IDE
  Show dependency treegraph
 
Reported: 2024-03-14 12:33 UTC by Cor Nouws
Modified: 2024-10-22 19:32 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cor Nouws 2024-03-14 12:33:35 UTC
Open Basic editor
Edit one of the Application macro's.
Go to the start of a line with multiple vars, expressions, *
press Ctrl+Right
  > this selects _two_ strings
should one

found in Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 56767830b81fa21382b87cf43d78b1c73ca5dbd8
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 Rafael Lima 2024-03-28 13:44:37 UTC
This is actually a very old bug... Ctrl + Left/Right has never worked well for me in the Basic editor.

For instance, consider the cursor is in the first position of the following line:

Global oKeyHandler As Object

If you press Ctrl+Right the cursor will go to the end of oKeyHandler. In any other code editor, the cursor would go to the beginning of oKeyHandler.

I'd say the problem is in TextView::KeyInput, located in:
/core/vcl/source/edit/textview.cxx
Comment 2 Cor Nouws 2024-04-17 18:57:53 UTC
(In reply to Rafael Lima from comment #1)
> This is actually a very old bug... Ctrl + Left/Right has never worked well
> for me in the Basic editor.
IIRC, it did for me... 
Starting (random) 5.0.6.3 shows it behaved as expected in that version > bibisectrequest.

> ...
> I'd say the problem is in TextView::KeyInput, located in:
> /core/vcl/source/edit/textview.cxx
Will look into that.
Comment 3 Aron Budea 2024-09-22 09:29:39 UTC
The regression started from the following commit, bibisected using repo bibisect-linux-64-7.0. Adding CC: to Andreas Heinisch.

https://git.libreoffice.org/core/commit/992c2e82e29ed68e40fe61303d16762604003121
Author:     Andreas Heinisch <andreas.heinisch@yahoo.de>
AuthorDate: Sat Jan 11 11:54:52 2020 +0100
Commit:     Noel Grandin <noel.grandin@collabora.co.uk>
CommitDate: Tue Feb 11 17:39:52 2020 +0100

    tdf#57879 - Expand word boundaries to include connector punctuations
Comment 4 Andreas Heinisch 2024-09-25 07:59:14 UTC
Imho the implemetation of this feature is correct. However, consider the following line where the "|" indicates the position of the caret:

|Global oKeyHandler As Object

In the function TextView::CursorWordRight I call xBI->nextWord where the function positions the cursor after the oKeyHandler:

Global oKeyHandler| As Object

So, imho there is a problem in BreakIteratorImpl::nextWord where the startPos is 0:

result = LBI->nextWord(Text, nStartPos, rLocale, rWordType);

It should not jump over the next word if the cursor is at the beginning of a word.
Comment 5 Commit Notification 2024-10-01 20:40:04 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/489613b93846d77a8ee33f5069f079c59dee563b

tdf#160202 - Don't extend selection over two words

It will be available in 25.2.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 6 Commit Notification 2024-10-22 19:32:44 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

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

tdf#160202 - Don't extend selection over two words

It will be available in 24.8.3.

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.