Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 425847

Summary: Staging View commit message area gets easily corrupted when hard wrap is switched on
Product: [Technology] EGit Reporter: Stefan Lay <stefan.lay>
Component: UIAssignee: Project Inbox <egit.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: markus.kell.r, matthias.sohn, robin
Version: 3.3   
Target Milestone: 3.3   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 426009    
Bug Blocks:    
Attachments:
Description Flags
Fix hard-wrap by enabling soft-wrap none

Description Stefan Lay CLA 2014-01-16 03:54:21 EST
The issue was introduced with commit 3c58e4ed5ec994307ffb20fb78ec2269e04ce392 (Use scrolling instead of soft-wrap in commit message text field)

When the commit message area is corrupted the cursor position is not the position anymore where characters are inserted but some lines above

Steps to reproduce:
- The hard-wrap has to be switched on in the prferences
- Start typing until a hard-wrap is made by the editor. 
- Now press enter. 
- The cursor is now one line above the position where characters are inserted.
Comment 1 Robin Stocker CLA 2014-01-16 07:42:22 EST
Confirmed. I suspect this might be a bug in StyledText's BidiSegmentListener support in conjunction with SWT.H_SCROLL.

@Markus: Do you know of such a bug? The code using this is in EGit's SpellcheckableMessageArea.

See also bug 424846, which is about making this configurable. The quickest fix would be to revert the commit which changed SWT.WRAP to SWT.H_SCROLL.
Comment 2 Markus Keller CLA 2014-01-16 12:11:53 EST
Created attachment 239072 [details]
Fix hard-wrap by enabling soft-wrap

The problem is that the StyledText implementation skips all support for intra-line wrapping unless the widget is created with SWT.WRAP (or setWordWrap(true) is called).

But a segment listener that inserts line breaks needs the wrapping support; just not the auto-wrapping at a certain line width.

A quick workaround is to call setWordWrap(true) in EGit's hard-wrap mode, see the attached patch. Drawbacks:
- If the message area is too narrow, then you also get real soft-wraps (like in older EGit versions)
- StyledText always shows a horizontal scroll bar (bug 425907, fixed in master)

I'll see if the StyledText could be convinced to perform intra-line wrapping as soon as a segment listener inserts a line break.
Comment 3 Markus Keller CLA 2014-01-16 12:34:25 EST
(In reply to Markus Keller from comment #2)
> Created attachment 239072 [details] [diff]
> Fix hard-wrap by enabling soft-wrap

This contribution complies with http://www.eclipse.org/legal/CoO.php
Comment 4 Markus Keller CLA 2014-01-17 12:30:10 EST
(In reply to Markus Keller from comment #2)
> I'll see if the StyledText could be convinced to perform intra-line wrapping
> as soon as a segment listener inserts a line break.

I've fixed StyledText bug 426009 in master, so this bug will disappear in 4.4.

The workaround from comment 2 is necessary for SWT < 4.4.

(In reply to Robin Stocker from comment #1)
> See also bug 424846, which is about making this configurable. The quickest
> fix would be to revert the commit which changed SWT.WRAP to SWT.H_SCROLL.

That would also be a good solution ;-)
Comment 5 Markus Keller CLA 2014-01-24 10:28:11 EST
http://git.eclipse.org/c/egit/egit.git/commit/?id=3c58e4ed5ec994307ffb20fb78ec2269e04ce392 should be reverted until EGit requires SWT 4.4. I don't see a way to make this work without the recent fixes in StyledText.
Comment 6 Matthias Sohn CLA 2014-01-24 19:20:58 EST
(In reply to Markus Keller from comment #5)
> http://git.eclipse.org/c/egit/egit.git/commit/
> ?id=3c58e4ed5ec994307ffb20fb78ec2269e04ce392 should be reverted until EGit
> requires SWT 4.4. I don't see a way to make this work without the recent
> fixes in StyledText.

pushed revert for review
https://git.eclipse.org/r/#/c/21077/
Comment 7 Robin Stocker CLA 2014-01-25 10:49:52 EST
(In reply to Matthias Sohn from comment #6)
> pushed revert for review
> https://git.eclipse.org/r/#/c/21077/

Merged: https://git.eclipse.org/c/egit/egit.git/commit/?id=16c186fe543f8d9a45c64f066c6f00230581595a

I think the `setAlwaysShowScrollBars(false)` part of the original patch was ok, so here's a change to reintroduce just that:

https://git.eclipse.org/r/21080

@Markus Keller: Thanks very much for your help and the platform fixes!
Comment 8 Robin Stocker CLA 2014-01-26 08:08:39 EST
(In reply to Robin Stocker from comment #7)
> I think the `setAlwaysShowScrollBars(false)` part of the original patch was
> ok, so here's a change to reintroduce just that:
> 
> https://git.eclipse.org/r/21080

Merged by Matthias:

https://git.eclipse.org/c/egit/egit.git/commit/?id=8b3603ac60fe1e9cfdf906ffc11134cd36610b12