Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3552 closed Bug (No Bug)

SciTE 3.7.3 bug: #Region & #EndRegion not working properly when it contains "Case" statements

Reported by: gil900 Owned by: Jos
Milestone: Component: SciTE4AutoIt
Version: 3.3.14.2 Severity: None
Keywords: Cc:

Description

$var = 1
Switch 1

	#Region @#%@

		Case 1


		Case 2

	#EndRegion

	#Region &@$%
		Case 3

		Case 5
	#EndRegion

EndSwitch

The option to collapse/uncollapse the whole region is not working properly. it collapsing until the first "case" statement and not until the #EndRegion

Attachments (0)

Change History (4)

comment:1 Changed 7 years ago by mLipok

  • Resolution set to No Bug
  • Status changed from new to closed

This is a wrong use of AutoIt "syntax", and philosophies.
Your region ranges are poorly defined.
You can not, write anything between Switch and first Case, this just do not make any sense.
I do not see any logic in this way of use Switch...Case...EndSwitch++#Region/#EndRegion

Here are examples of proper way showing how to use #Region in this case:

$var = 1
#Region @%@ outer
Switch 1
	Case 1
		; .....
		#Region @%@ inner 1
		; .....
		#EndRegion @%@ inner 1
		; .....
	Case 2
		; .....
		#Region @%@ inner 2
		; .....
		#EndRegion @%@ inner 2
		; .....
	Case 3
		; .....
		#Region &@$% inner 3
		; .....
		#EndRegion &@$% inner 3
		; .....
	Case 5
		; .....
		#Region &@$% inner 4
		; .....
		#EndRegion &@$% inner 4
		; .....
EndSwitch
#EndRegion @%@ outer

btw.
Personally I prefer this kind of code descriptions:

$var = 1
#Region @%@ outer
Switch 1 ; main description for entire switch region
	Case 1 ; some description for case 1 region
		; .....
	Case 2 ; some description for case 2 region
		; .....
	Case 3 ; some description for case 3 region
		; .....
	Case 5 ; some description for case 5 region
		; .....
EndSwitch
#EndRegion @%@ outer
Last edited 7 years ago by mLipok (previous) (diff)

comment:3 Changed 7 years ago by Jos

I would say there is basically nothing wrong with using it like that, but you need to remember that SciTE only does basic lexing and not syntax interpretation. In this case the Case statement will Close the previous Fold Header ( being a #region) en start a new Fold level, since that is what is needed for a Case line.
So it is not a bug but agree it looks strange.
Jos

comment:4 Changed 7 years ago by mLipok

Try this:

Switch 1
	ConsoleWrite("! 1" & @CRLF)
	Case 1
EndSwitch

You will get:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /test /run /prod /ErrorStdOut /in "Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3" /UserParams    
+>21:11:37 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:00000415  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0415)  CodePage:65001  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Michał\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Michał\AppData\Local\AutoIt v3\SciTE 
- *** Compile in Test mode skipping Tidy; Au3Stripper; Resource updating and Versioning to speed up the process. ***
>Running AU3Check (3.3.15.2)  from:C:\Program Files (x86)\AutoIt3  input:Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3
"Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3"(2,2) : error: syntax error
	ConsoleWrite
	^
"Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3"(2,2) : error: Statement cannot be just an expression.
	ConsoleWrite
	^
"Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3"(3,2) : error: syntax error
	Case
	^
"Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3"(3,2) : error: Statement cannot be just an expression.
	Case
	^
"Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3"(3,8) : error: Statement cannot be just an expression.
	Case 1
	~~~~~~^
"Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3"(4,1) : error: Statement cannot be just an expression.
EndSwitch
^
Z:\AutoItPortable\App\SciTE\_TESTING\Track_3552_v2.au3 - 6 error(s), 0 warning(s)
!>21:11:38 AU3Check ended. Press F4 to jump to next error.rc:2
+>21:11:38 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 1.157

I know this is rather this case:

Switch 1
	#Region 1
	Case 1
		#EndRegion 1
EndSwitch

But this is very strange to write anything else than Case in first line just after Switch.
You must to agree with me that in this scenario #Region and #EndRegion are on different FoldingLevel.

Also in this case:

Switch 1
	Case 1
		#Region This is inside Case 1 Folding group
		If 1 Then
		EndIf
	Case 2
		#EndRegion 	This is outsde Case 1 Folding group
EndSwitch

#Region and #EndRegion are on different Folding level and this could not be taken any way, this is just irrational.

Version 1, edited 7 years ago by mLipok (previous) (next) (diff)

comment:5 Changed 7 years ago by Jos

Lines starting with an # are ingnored by AutoIt3, so let's not make this more complex as it is.
My reply merely stated why things are happening as experienced and didn't want to have/start a debate on code formatting in TRAC. :)

Jos

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jos.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.