cedrtain words always showing as different even if source is identical

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paulkienitz
    Journeyman
    • Nov 2005
    • 16

    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.
  • Chris
    Team Scooter
    • Oct 2007
    • 5538

    #2
    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

    Comment

    • paulkienitz
      Journeyman
      • Nov 2005
      • 16

      #3
      Originally posted by Chris
      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?

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 15997

        #4
        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

        Comment

        • paulkienitz
          Journeyman
          • Nov 2005
          • 16

          #5
          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.

          Comment

          • Aaron
            Team Scooter
            • Oct 2007
            • 15997

            #6
            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

            Comment

            Working...