Author Topic: Comment coloring && bug in Color options  (Read 950 times)

jporkkahtc

  • Senior Community Member
  • Posts: 1881
  • Hero Points: 182
  • Text
Comment coloring && bug in Color options
« on: October 21, 2019, 02:49:03 pm »
#1: The UI bug:
In ColorCoding, "Color to end of line" allows free text entry, but it should not. There is a list of valid entries.
Anything not in this list is ignored.

#2: Weird UI
  Why does "When end delimiter is not on the same line" get hidden instead of disabled?
  Its weird having the UI rearrange when you enter text in "End Delimiter.

#3:
In Windows *bat files, comments start with :: or rem.
In Slick it has checked "Match start delim only if first non-blank"

This isn't quite right, for example
Code: [Select]
echo this :: rem echo that
echo this & :: rem echo that
The first line has no comment, but the second line does.
The "::" is the first non-blank character in the statement.

I found a way to fix this: Add "& *::" as a regex comment.

mjdl

  • Senior Community Member
  • Posts: 142
  • Hero Points: 16
  • SE 24.0.0.8 hotfix 5 x64 Windows 10 x64 v1909
Re: Comment coloring && bug in Color options
« Reply #1 on: October 21, 2019, 05:49:09 pm »
My regex knowledge is only elementary,
but surely the case where & is preceded by a quote " should also be considered, so the quoted text in the batch file line

echo this "& :: rem echo that"

is excluded from comment colouring.

I used the Perl regex [^"]& *:: to do that in a new colouring specification for the Batch file type.


jporkkahtc

  • Senior Community Member
  • Posts: 1881
  • Hero Points: 182
  • Text
Re: Comment coloring && bug in Color options
« Reply #2 on: October 21, 2019, 09:52:09 pm »
Tricky because
Code: [Select]
echo "this & :: rem echo that"
Should also be excluded!

Hmm... Slick seems to handle this already. Just using "& *::" works correctly for both of these cases.
Does it not work for you?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5010
  • Hero Points: 417
Re: Comment coloring && bug in Color options
« Reply #3 on: October 22, 2019, 03:47:54 am »
This works because SlickEdit has a color coding definition for double quoted strings. In order for that regex to have an effect inside the double quoted string, you would have to define it as a child item of the double quoted string definition.

We will fix issues #1 and #3.   

jporkkahtc

  • Senior Community Member
  • Posts: 1881
  • Hero Points: 182
  • Text
Re: Comment coloring && bug in Color options
« Reply #4 on: October 22, 2019, 05:04:59 pm »
Interesting... The quirks and inconsistencies in bat files are endless.
Looks like the (reasonable) comment cases are
Code: [Select]
& ::
|| ::
&& ::

"&" joins two statements, running them sequentially.
"|" does as well, with a pipe.

"&&" is like if, if the left command is successful, also run the right command
"||" is like if, if the left command is failed, also run the right command

Code: [Select]
dir C:\Unknown && echo Success
dir C:\Unknown || echo Failed


#1:
Code: [Select]
echo this & :: echo thatIs a comment

#2:
Code: [Select]
echo this | :: echo thatIs an error - so not really a comment case.

#3:
Code: [Select]
echo this || :: echo thatIs a comment

#4:
Code: [Select]
echo this && :: echo thatIs a comment


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5010
  • Hero Points: 417
Re: Comment coloring && bug in Color options
« Reply #5 on: October 22, 2019, 05:12:01 pm »
Thanks for the test cases. Should be easy to add comment regex for these

mjdl

  • Senior Community Member
  • Posts: 142
  • Hero Points: 16
  • SE 24.0.0.8 hotfix 5 x64 Windows 10 x64 v1909
Re: Comment coloring && bug in Color options
« Reply #6 on: October 22, 2019, 05:47:45 pm »
Tricky because
Code: [Select]
echo "this & :: rem echo that"
Should also be excluded!

Hmm... Slick seems to handle this already. Just using "& *::" works correctly for both of these cases.
Does it not work for you?
I think I got this all wrong as a result of not testing enough. Ignore my comment.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5010
  • Hero Points: 417
Re: Comment coloring && bug in Color options
« Reply #7 on: October 23, 2019, 01:48:23 am »

#4:
Code: [Select]
echo this && :: echo thatMy testing indicates this instance of :: is not a comment

jporkkahtc

  • Senior Community Member
  • Posts: 1881
  • Hero Points: 182
  • Text
Re: Comment coloring && bug in Color options
« Reply #8 on: October 23, 2019, 09:14:10 pm »
You're right.
But this is:
  echo this && rem  echo that
I guess I assumed :: and rem are the same, but they aren't.
I think that :: isn't really intended as a comment, its just a degenerate label (like for goto).