Comment Symbol with 'CTRL+B' not in front of indentation

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
nalor
Enthusiast
Enthusiast
Posts: 121
Joined: Thu Apr 02, 2009 9:48 pm

Comment Symbol with 'CTRL+B' not in front of indentation

Post by nalor »

Hi!
Something really annoying is the following behaviour:

Code: Select all

If #True
   Debug "test"
   
   If Not #False
   EndIf
EndIf
When you select the line with 'debug' and press CTRL+B to mark it as comment it looks like this: '; debug "test"' (the comment symbol ';' is in front of the indentation)
In case you'd like to insert a new line into the 2nd if the whole line is moved to the beginning of the line because of the ';' from the comment being the first character in the line above.... destroying the complete indentation! (just position the cursor after the '#false' and press enter after commenting out the debug line and you'll see what I mean).

It would be better if a comment with CTRL+B would insert the ';' AFTER the indentation of the line - ' ;debug "test"'

Or maybe make this an option in the editor preferences.... but currently I don't know how I could stop this behaviour...

Thanks!
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Comment Symbol with 'CTRL+B' not in front of indentation

Post by Tenaja »

I use tabs instead of spaces. That way, only the lines at the left margin (i.e. Procedure declarations and EndProcedure) have their indentation altered.
nalor
Enthusiast
Enthusiast
Posts: 121
Joined: Thu Apr 02, 2009 9:48 pm

Re: Comment Symbol with 'CTRL+B' not in front of indentation

Post by nalor »

Usually I also use tab's instead of spaces - but in my case this don't make a differnce when it comes to indentation? My example is working identically - regardless if I indent by tab or by space...

I think comment lines should simply be ignored by the indentation mechanism.
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Re: Comment Symbol with 'CTRL+B' not in front of indentation

Post by Le Soldat Inconnu »

Yes, when you comment ";" is placed on start line and not before indentation.
But when you reset indentation with Ctrl+I, ";" come back with good indentation

Example

Code: Select all

If Truc = 0
  Test + 1
EndIf
i comment

Code: Select all

If Truc = 0
;  Test + 1
EndIf
i set indent with ctrl + I

Code: Select all

If Truc = 0
  ;  Test + 1
EndIf
so i get indentation before and after !

The best solution for me :

Code: Select all

If Truc = 0
  Test + 1
  If Test > 2
    Toto = Test + 4
  EndIf
EndIf
i comment

Code: Select all

If Truc = 0
  ; Test + 1
  ; If Test > 2
  ;   Toto = Test + 4
  ; EndIf
EndIf
So, i keep indentation from fisrt commented line, and i keep indentation inside comment
if i do Ctrl + I, indentation don't change
if i remove comment, i don't lost indentation on line "Toto = Test + 4"

Thanks
LSI
Post Reply