Bug 569626 - [StyledText] transitioning to variable line height erroneously moves visible area
Summary: [StyledText] transitioning to variable line height erroneously moves visible ...
Status: CLOSED DUPLICATE of bug 570242
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.19   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 570342
Blocks: 553849
  Show dependency tree
 
Reported: 2020-12-10 08:56 EST by Mickael Istria CLA
Modified: 2021-03-01 03:34 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 Mickael Istria CLA 2020-12-10 08:56:10 EST
Assuming the current 1st line in the StyledText is partially cropped, if one switches from fixed line height (default) to variable line height (eg by enabling word wrap), then the visible area moves for no good reason. It will basically move the content so that the top line is the one that was previously just after the "partial" one.
In cases where there is no layout change (eg enabling word wrap when there is nothing long enough to wrap), nothing should move, or it gives an impression of being "jumpy".
This does quite visibly affect code minings as well, which use the setLineVerticalIndent() method.
Comment 1 Mickael Istria CLA 2020-12-10 08:57:06 EST
Here is a test case that shows the issue

@Test
public void test_notFixedLineHeightDoesntChangeLinePixelIfUnnecessary() {
	String _50lines = IntStream.range(1, 50).mapToObj(Integer::toString).collect(Collectors.joining("\n"));
	text.setText(_50lines);
	text.setSize(500, 200);
	int line = 30;
	int offset = text.getOffsetAtLine(line);
	text.setSelection(offset);
	text.showSelection();
	int firstLinePixel = text.getLinePixel(0);
	text.setWordWrap(true); // make non fixed line height
	assertEquals(firstLinePixel, text.getLinePixel(0)); // fails, window content moved by 10pixels.
}
Comment 2 Mickael Istria CLA 2020-12-10 09:01:08 EST
I think this is caused by topIndexY not being set to useful value in fixed line height, while variable line height expects it to be set.
Comment 3 Eclipse Genie CLA 2020-12-10 09:28:13 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/173661
Comment 5 Andrey Loskutov CLA 2021-01-13 14:56:12 EST
(In reply to Eclipse Genie from comment #4)
> Gerrit change
> https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/173661 was
> merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=62873ac24d92f573108ea676aaf2559a7deaec93

This caused regression in bug 569626.
Comment 6 Lakshmi P Shanmugam CLA 2021-02-05 04:07:41 EST
Resetting target, please retarget as required.
Comment 7 Sravan Kumar Lakkimsetti CLA 2021-02-26 03:53:06 EST
(In reply to Andrey Loskutov from comment #5)
> (In reply to Eclipse Genie from comment #4)
> > Gerrit change
> > https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/173661 was
> > merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > ?id=62873ac24d92f573108ea676aaf2559a7deaec93
> 
> This caused regression in bug 569626.

Andrey, 

Can you please point to the regression bug? the above mentioned bug is current bug.

Removing the target now.  Please retarget if necessary
Comment 8 Andrey Loskutov CLA 2021-02-26 04:16:44 EST
(In reply to Sravan Kumar Lakkimsetti from comment #7)
> (In reply to Andrey Loskutov from comment #5)
> > (In reply to Eclipse Genie from comment #4)
> > > Gerrit change
> > > https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/173661 was
> > > merged to [master].
> > > Commit:
> > > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > > ?id=62873ac24d92f573108ea676aaf2559a7deaec93
> > 
> > This caused regression in bug 569626.
> 
> Andrey, 
> 
> Can you please point to the regression bug? the above mentioned bug is
> current bug.
> 
> Removing the target now.  Please retarget if necessary

See bug 570342 comment 3. 
Mickael, I believe this bug can be closed now?
Comment 9 Mickael Istria CLA 2021-03-01 03:34:05 EST
Yes, I think this case was covered as part of bug 570242

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