LUA - line comment overtaking the block comment

LUA - line comment overtaking the block comment

5
NewbieNewbie
5

    Apr 07, 2005#1

    I am using the Lua syntax word file. In Lua line comments start with a "--". Block comments in Lua start with a "--[[" and end with a "]]".

    My problem is that block comments simply are not highlighted properly. Only the first line is highlighted and the rest of the block of code is treated as though its not a comment. I have figured out that it is as a result of the "--" beginning both a line comment and a block comment.

    Other editors I have used - such as EditPlus - seem to handle this just fine. Any ideas on how to get around this seeming limitation?

    6,656559
    Grand MasterGrand Master
    6,656559

      Apr 08, 2005#2

      Try to change the order of Line Comment and Block Comment definition in the wordfile. Maybe this helps. A similar problem was discussed at Multiple styles of commenting?

      If this does not help and after -- as line comment always a space follows, you could use "Line Comment Num = 3-- " without the "" - note the additional space after --.

      If nothing works, post a small Lua example here for us to test it. Do not post the the Lua syntax highlighting definition, because we can download it by ourselves.

      5
      NewbieNewbie
      5

        Apr 08, 2005#3

        There is not always a space behind the '--' line comment unfortunately. I could comment that way but there is no guarantee others will.

        With regard to trying to switch up the order and making:
        Line Comment = --[[
        Block Comment = --

        This doesnt work either because when a true line comment is reached ( '--') then a block comment begins until it finds the Block Comment Off assignment - which is a double bracket ]].

        Here is an example snippet of comments:

        Code: Select all

        -- $Id: UiAdpConv.lua,v 1.16.2.2 2005/04/07 19:37:39 lmh Exp $
        
        -- The following 4 lines should all be considered code by the syntax file.
        Tbl = { 1, 2, 3, 4, 5 }
        for J, K in pairs(Tbl) do
          print(K)
        end --for (here is  comment at the end of the block)
        
        -- This line and the following block comment should all be colored in 
        -- the appropriate syntax highlited color.
        
        --[[ LuaDoc
        
        {Rem}CloseFnc = A function that take in one table after the window has been
          closed and handles what happenes once the window has closed.
        {Rem}ExtraButton = If true an 'Apply' button will be passed to the
          W.StandardClosure function and located on the left hand side.
        {Rem}OpenList = A table suitable for display in an open list. The first item
          should be a default value.
        {Rem}OpenListGroup = A String to be displayed in the group around the open list.
          Default value is Conversion value.
        {Rem}OpenListFrmtStr = A string to be passed to an open list's FrmtStr.
        
        LuaDoc ]]
        Thanks from Michigan!

        Scott

        6,656559
        Grand MasterGrand Master
        6,656559

          Apr 10, 2005#4

          Ok. I played a little with your example and found no perfect solution for your problem. You should mail it to IDM and ask for an improvement in a future release for line and block comments starting with the same character(s).

          As workaround you could use
          1. Code: Select all

            /L20"Lua" Line Comment Num = 3--  Block Comment On = --[[ Block Comment Off = ]] File Extensions = LUA BIN
          2. and run the following regular expression replace in UltraEdit style on all of your Lua files to make sure that all line comments have at least one space immediately after the '--':

            Find What: --^([~ ^[^p]^)
            Replace With: -- ^1
          This regular expression does not change the block comments and it does not add a space after '--', if there is already one space. In your example only a space at line comment --for (here is inserted.

          5
          NewbieNewbie
          5

            Apr 13, 2005#5

            Thanks for the response. I'll play with that and probably email this as a future request to IDM.

            7

              May 11, 2006#6

              I'm currently using UltraEdit version 12.

              Using the LUA syntax highlight, I notice 2 things wrong:

              -----------------------------------------------
              1) Currently when you begin typing a string in the middle of code, the syntax highlight appears on multiple lines. In Visual Studio, the coloring is limited to a single line. Is there a way to prevent strings from coloring multiple lines in LUA Script?

              -----------------------------------------------
              2) Finally, single line comments and multi-line comments in LUA script are not treated differently.

              Single Line Comment: -- This is a comment
              Multi-Line Comment: --[[ This is a multiline comment ]]

              Note that in both situations, they start with a --. This basically means that multiline comments are always treated as single line comments.

              I have read the posts above. The suggestion is to always have a space after the '--'. I think this is a cheap way out and I would rather the coloring be done properly.

              -----------------------------------------------
              If anyone can help, I would greatly appreciate it. I couldn't buy this editor if it had so many small issues with syntax highlighting. If they're fixable, that would be awesome.

              PS: If you would like to see the LUA syntax highlighting code in the wordfile.txt file, just request that I post it. I'd be more than happy to.

              Take care.

              6,656559
              Grand MasterGrand Master
              6,656559

                May 11, 2006#7

                1) Add keyword DisableMLS at the LUA language definition line. See UltraEdit help page Syntax Highlighting for details about this keyword.

                2) You have read already the posts above. Nothing new from IDM for this issue. I personally think that having a space after line comment -- is not really a pain, isn't it. I think, it makes the line comment better readable.

                7

                  May 11, 2006#8

                  Thank you for your reply.

                  #2 is disappointing, but I guess I'll have to wait for an enhancement :)