Wrong brace matching in some cases on syntax highlighted SAS log file with UEP v16.00 (fixed)

Wrong brace matching in some cases on syntax highlighted SAS log file with UEP v16.00 (fixed)

49
Basic UserBasic User
49

    Jul 06, 2017#1

    I know this topic has been discussed few times before but I couldn't find an issue similar to the one I am having.

    I am using UltraEdit Portable v16.00 on a Windows 7 machine. I have a SAS log file which has the following lines in it:

    Code: Select all

    SYMBOLGEN:  Macro variable ALLACCTS resolves to ((prod_typ_code = 'SDB' or prod_typ_code = 'DEP' and prod_id not in('DDA','DDA 
                B','DDA N','NPCA','NPCA1','NPCA3','NPCAC','NPCAE','NSAVC','NSAVR')) or (prod_typ_code = 'DEP' and prod_id in('DDA','DDA 
                B','DDA N','NPCA','NPCA1','NPCA3','NPCAC','NPCAE','NSAVC','NSAVR')) or (prod_typ_code in ('CARD','VISA')) or 
                (prod_typ_code in ('INVS','INVT','MUF','TRST')) or (prod_typ_code = 'ISI') or (prod_typ_code = 'MTG') or (prod_typ_code 
                in ('CL','LAS')))
    
    I have syntax highlighting ON and the .uew file is attached. The braces match just fine in the first line but when I click the mouse after the keyword "or" on 2nd line, it should match to the brace just before the keyword "or" in the 3rd line. But instead it matches the the brace before that. Similar behavior happens when I click on the brace after the keyword "or" on the 3rd line. It should match to the brace on the same line but instead it matches the very last brace in the code.

    I have been trying to figure this out for 2 days now but couldn't get anywhere.

    Any help will be greatly appreciated.

    Thanks.
    Subhash.

    PS. If I add the tag "Noquote" in the file definition, then it works OK but that is not what I want. The code also works fine if highlighted as an XML file with the stock uew file.
    sas.zip (6.08 KiB)   56

    6,680583
    Grand MasterGrand Master
    6,680583

      Jul 07, 2017#2

      The wordfile contains some minor errors:
      • SAS_LANG is an unknown keyword for UltraEdit and therefore was removed by me in attached improved version of the wordfile.
        The list of supported language marker keywords can be found at bottom of help page Syntax Highlighting and on forum topic Template for syntax highlighting language wordfile.
      • Added EnableMLS to explicitly enable multi-line string highlighting although this is the default with DisableMLS not present in first line.
      • I sorted the list of Delimiters using a (not yet published) macro which would not be necessary as the list of delimiters does not need to be sorted.
      • Macro TestForDuplicate found lots of duplicate keywords. I removed the duplicates not really used for syntax highlighting, i.e. every second occurrence of a keyword.
      • Macro TestForInvalid found some invalid keywords, most in list of operators. I fixed them.
      However, the wordfile is not responsible for not correct working brace matching.

      The reason is an error in code of UltraEdit (bug). I could reproduce the issue also with UE v22.20.0.49 (last on XP) and UE v24.10.0.24 (currently latest).

      This specific issue with brace matching not working as it should with strings within the braces is known since March 2017, see Weird matching brace block selection when caret is in a string inside parentheses.

      There is nothing which a user could do to fix this bug in code of UltraEdit than reporting the issue to IDM support by email to get it fixed in a future version or alternatively code an UltraEdit script which replaces built-in brace matching command at least for a specific language.

      Interesting on this issue was to see that reverse brace matching using Ctrl+B works with setting caret to first or second ) in third line. Just the forward brace matching with caret after or in second line does not work.

      Please report this issue to IDM support. I will do the same to increase the priority for fixing it in a future version of UltraEdit. This example is very good to reproduce the wrong behavior of brace matching feature of UltraEdit.

      Update: The improved wordfile without color and font style settings is included in RAR archive attached to my next post.
      Best regards from an UC/UE/UES for Windows user from Austria

      49
      Basic UserBasic User
      49

        Jul 07, 2017#3

        Thanks Mofi for the reply.

        As always, you are so thorough and quick with every issue. At least now I can stop spending more time trying to fix it. And yes, I forgot to mention in my previous post that the reverse matching for the same set of braces works just fine, with Ctrl+B or highlighted. Only the forward matching has an issue.

        I reported the problem as bug report to IDM. Please do the same. Hope it is fixed soon and may be that will be the time for me to upgrade to the latest version. LOL.

        Thanks again for your help and the improved wordfile. I will replace my current wordfile.

        Subhash.

        6,680583
        Grand MasterGrand Master
        6,680583

          Jul 07, 2017#4

          I did it, too. Here is what I wrote and what I attached.
          Mofi wrote:The issue described below can be reproduced by me with UE v22.20.0.49 on Windows XP and UE v24.10.0.24 on Windows 7. The commands "Go to matching brace" and "Select to matching brace" do not work correct with strings within the braces.

          This was reported first by forum member Miklos with forum topic http://forums.ultraedit.com/topic17253.html who has sent a bug report email to you and was reported a second time by forum member sssccc with forum topic http://forums.ultraedit.com/topic17432.html who still uses UEP v16.00. So this a definitely a long existing issue and the issue
          should be already in your database.

          The steps to reproduce are:
          • Extract the files in attached RAR archive to a temporary folder and copy sas.uew into %APPDATA%\IDMComp\UltraEdit\wordfiles.
          • Start UltraEdit and open file MatchBraceTest.sas.
          • Load the macro file MatchBraceTest.mac and execute it.
          All test cases should be successful, but 4 test cases fail.

          The macro file with code as stored in MatchBraceTest.uem was created and tested first with UE v16.00.0.1040 and later executed also with newer versions which produce all the same test results.
          MatchBraceTest.rar (7.13 KiB)   39
          This RAR archive contains the files to reproduce the issue.
          Best regards from an UC/UE/UES for Windows user from Austria

          49
          Basic UserBasic User
          49

            Jul 07, 2017#5

            Thanks Mofi.
            Let's see what IDM comes up with.

            Subhash.

            6,680583
            Grand MasterGrand Master
            6,680583

              Jan 25, 2019#6

              The brace matching behavior with caret inside a string syntax highlighted as string is fixed with UltraEdit for Windows v25.20.0.156 according to my tests.
              Best regards from an UC/UE/UES for Windows user from Austria

              49
              Basic UserBasic User
              49

                Aug 09, 2019#7

                That's good to hear. Thanks Mofi for your efforts.

                Sorry, saw your post just today although it has been a few months.

                Subhash.