Bug 203880 - Compare should support ignore leading white space/ignore trailing white space
Summary: Compare should support ignore leading white space/ignore trailing white space
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 76299 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-18 16:08 EDT by Michael Y Kwong CLA
Modified: 2014-07-09 21:28 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Y Kwong CLA 2007-09-18 16:08:09 EDT
Currently the user can choose to Ignore white space in the General Preferences page.  This is useful, but there are situations when more fine grained control is needed.  In some cases, white space inside the source lines are actually significant, but what is not significant are trailing white space (which may be inserted removed as a result of ftp, platform differences, etc).  It would be very useful if the Compare can be set to ignore not all white space, but just trailing (or leading) white space.
Comment 1 Tomasz Zarna CLA 2007-09-19 08:56:40 EDT
I see your point Michael. Distinguishing between significant space and nonsignificant could be a useful things. My only concern is the criteria you suggested (i.e. ignoring only trailing and leading white space characters). What do you think about excluding from the ignore action white spaces enclosed with " instead? In other words, I would ignore all white spaces except the ones inside strings in Java classes (for example).
Comment 2 Michael Y Kwong CLA 2007-09-19 12:11:02 EDT
Good question.  I think distinguishing between significant and non-significant white space is really what I'm looking for.  But the definition of what is significant would be file type dependent.  Does that mean we will have an extension point to allow people to contribute code that will determine what white space is significant based on language/file type?
Comment 3 Michael Valenta CLA 2007-09-19 12:25:34 EDT
In essence, we already have the extension point (i.e. JDT provides the JavaMergeViewer). What would be required is additional API that delegates the determination of what is whitespace to the viewer.
Comment 4 Tomasz Zarna CLA 2008-01-29 05:24:08 EST
Another solution for the given problem can be a set regular expressions describing differences which are not significant from the user point of view. This is how such expression could look for preceding and trailing white spaces:

^\s?.*\s?$

Initially, the rule would work for all file types. At the same time, I would leave an option to disable all custom rules for a current comparison (an option in the context menu similar to "Ignore White Spaces").

Nevertheless, I think an ideal solution would be to combine these custom rules with a viewers. This way the user could control which rules are activated for which file types.

On the other side, I'm not sure how hard would it be to use a set of such rules in the current differencing mechanism.
Comment 5 Tomasz Zarna CLA 2008-01-29 06:01:27 EST
*** Bug 76299 has been marked as a duplicate of this bug. ***
Comment 6 Daniel Sokolowski CLA 2014-07-02 12:03:58 EDT
Isn't this completed and should be closed off ?
Comment 7 Tomasz Zarna CLA 2014-07-07 06:25:07 EDT
Daniel, could you remind me where the option for ignoring _only leading/trailing whitespace chars_ is?
Comment 8 Daniel Sokolowski CLA 2014-07-09 21:28:15 EDT
Get into compare mode, example select two files right click 'Compare With > Each Other', the window that appears 'Right Click > Ignore Whitespace Characters' near the bottom. 

Thinking about this further, because this option is hidden, and I would guess you are not the only one that has missed it - I would recommend that this bug stay open but that an icon be added to the 'toolbar' at the top right in the compare window.