Bug 577737 - Regression: StyledText does not remember caret column after changing lines
Summary: Regression: StyledText does not remember caret column after changing lines
Status: CLOSED DUPLICATE of bug 576052
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.21   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks: 562676
  Show dependency tree
 
Reported: 2021-12-10 04:15 EST by Christoph Kaser CLA
Modified: 2021-12-10 04:51 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Kaser CLA 2021-12-10 04:15:37 EST
This changes from bug #562676 introduced a regression: the caret column does not persist when it is moved from the end of a long line to a short one and back again.

** Steps to reproduce ** 

Open a text editor (I reproduced it in the java editor).

Enter the following text:

a very very very long line
a short line

Position the caret at the end of line 1, press "cursor down", then "cursor up" on your keyboard.

** Observed behavior **
The caret is now in the middle of line 1.

** Expected behavior **
The caret should be at the end of line 1.
This was the behavior before this change, which was accomplished by storing the previous caret position in "StyledText.columnX". However, with this change, columnX is no longer read in 
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20Custom%20Widgets/common/org/eclipse/swt/custom/StyledText.java?id=4e0d3cef45c6b6512666f9d51e8154ed545bc57b#n2701
nor in
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20Custom%20Widgets/common/org/eclipse/swt/custom/StyledText.java?id=4e0d3cef45c6b6512666f9d51e8154ed545bc57b#n2805

(See also Bug #5935 and #108792)
Comment 1 Andrey Loskutov CLA 2021-12-10 04:29:56 EST
I can't reproduce on Linux / master.
Which exact Eclipse version are you using?
Comment 2 Christoph Kaser CLA 2021-12-10 04:44:19 EST
I am really sorry, I was really sure I tried it with the newest version, but turns out a new version was released...

The bug occurred with:
Version: 2021-09 (4.21.0)
Build id: 20210910-1417

I just downloaded the newest version and can't reproduce.
Version: 2021-12 (4.22.0)
Build id: 20211202-1639


The only remaining question might be whether a check for this behavior could be added to a unit test so it won't break again.

Anyway, sorry for the spam!
Comment 3 Rolf Theunissen CLA 2021-12-10 04:51:46 EST
Tests have been added as well, see Bug 576052

*** This bug has been marked as a duplicate of bug 576052 ***