Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2005
    Posts
    12

    Default cedrtain words always showing as different even if source is identical

    I'm using 4.2.5 to synchronize code between two different implementations, one in Java and one in C#. When I compare a .java file to a .cs file, there are certain words which always highlight as a difference even if they do not actually differ. The most common words which do this are "true" and "false". The word "do" also does this. Lots of other language keywords do not have this problem, such as "if" and "else". Another word this happened with was "union", which isn't a keyword in these languages.

    Is this a bug or a feature? If it's a feature, how do I turn it off? If it's a bug, is there some adjustment to the session settings or comparison rules which can work around it?

    If I manually change the format from "detected" to "everything else", the problem does go away, but I apparently have to do that over with each file I open.

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,730

    Default

    Beyond Compare will mark text as different if it has different grammar element types, even if the text in the grammar element is the same. As an example, if text on the left is of grammar element comment and text on the right is of grammar element string, it will be marked as different even though the text might be the same.

    To determine the grammar element type of text, cursor into it. The grammar element type is displayed in the status bar at the bottom. You might need to edit your file formats for Java and C# (Tools > File Formats) so the grammar element types of the different text are the same.

    Other than editing file format grammar elements, another option is to use the same file format for both files. The highest file format in the Tools > File Formats list with a matching file mask is used. Editing the mask for the Java or C# format so it matches both files and moving it to the top of the list might resolve the issue.
    Chris K Scooter Software

  3. #3
    Join Date
    Nov 2005
    Posts
    12

    Default

    Quote Originally Posted by Chris View Post
    Beyond Compare will mark text as different if it has different grammar element types, even if the text in the grammar element is the same. As an example, if text on the left is of grammar element comment and text on the right is of grammar element string, it will be marked as different even though the text might be the same.

    To determine the grammar element type of text, cursor into it. The grammar element type is displayed in the status bar at the bottom. You might need to edit your file formats for Java and C# (Tools > File Formats) so the grammar element types of the different text are the same.

    Other than editing file format grammar elements, another option is to use the same file format for both files. The highest file format in the Tools > File Formats list with a matching file mask is used. Editing the mask for the Java or C# format so it matches both files and moving it to the top of the list might resolve the issue.
    Thanks for the explanation. Sure enough, it thinks that "true" is a keyword in one language and an identifier in the other. Maybe that's technically true, I don't know. And yes, if I set both sides to the same language, these words match again. (An interesting side effect is that when "bool" is compared to "boolean", it now highlights the entire word instead of just the differing letters.)

    The question this leaves is: is there any way to save the format override as part of the session?

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,908

    Default

    Hello,

    Yes, in the Text Compare, if you override the format and then use the Session menu -> Save Session, this saved session will load with the picked formats. Are you seeing different behavior?

    You can also edit the grammar of one format or the other so that "true" has a matching definition (keyword or identifier in both), if you want it to be regarded as equal when comparing these extensions. Then you wouldn't need to override the entire format detection.
    Aaron P Scooter Software

  5. #5
    Join Date
    Nov 2005
    Posts
    12

    Default

    I tried that. Next time I load the session, it's back to the default format. Likewise if I continue using the session on another file when it's already open.

  6. #6
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,908

    Default

    Hello,

    Before opening the saved session, on the Home screen select the saved Text Compare session and click Edit. Go to the Format tab, and select the appropriate formats for your files, then re-save. If you open this session, it should launch with the selected formats.

    After opening a session, if you drag and drop files onto either text pane, this should also use the current format.

    If you are still having trouble, please try updating to BC 4.2.6 (all BC 4.x updates are free for 4.x users), and if this is still troublesome, please email in:
    1) Your BCSupport.zip (Help menu -> Support; Export)
    2) A pair of sample files associated with a specific saved session
    3) Let us know which session to test from your included settings
    4) a link back to this forum thread for our reference.
    Aaron P Scooter Software

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •