PureBasic Forum
http://forums.purebasic.com/english/

[5.72-B1] Indentation still buggy
http://forums.purebasic.com/english/viewtopic.php?f=42&t=74575
Page 1 of 2

Author:  PureLust [ Sat Feb 08, 2020 8:08 am ]
Post subject:  [5.72-B1] Indentation still buggy

Since auto-indentation of Remarks (';') was implemented, the overall indentation is not working right.

[EDIT] I'n not sure if ";>" and ";<" are PBs defaults to force an indentation.
If not, please use indentation-keywords from your configuration.

In my case it's set to:
Code:
;>    before:  0    after:   2
;<    before:  0    after:  -2

Code:
; Example WITHOUT indentation keywords - I assume, that's how it should be.  (Hint: I use 2 x TAB before the ';')
(Code looks the same after typing and after reformatting it with 'format indentation (Ctrl-I))

If 1     ;
         ;
Else     ;
         ;
EndIf


Select A    ;
            ;
   Case 1   ;
            ;
   Case 2   ;
            ;
   Case 3   ;
            ;
   Default  ;
            ;
EndSelect


; Example WITH indentation keywords - see messed up result after typing the code
; (Looks like, wrong cursor Position is set, after auto-aligning the Remarks (';'). Remark-Alignment should not effect cursor position for next code-part - shouldn't it?)
; (code alignment-routine seems to work ok on 'format indentation' but not after pressing ENTER.)
; [EDIT] I just crosschecked it with PB 5.22 - indentation after pressing ENTER is correct in older Versions and faulty since Remark-alignment was implemented.)
; [Hint;]  ;>  should increase indentation by 2 after the EOL, and ;< should decrease indentation by 2 after EOL

If 1     ;>
         ;<
         Else  ;>
               ;<
            EndIf
           

            Select a    ;>
                        ;<
                        Case 1      ;>
                                    ;<
                              Case 2;>
                                    ;<
                                    Case 3      ;>
                                                ;<
                                          Default     ;>
                                                      ;<
                                          EndSelect
                                         
                                         
                                   
; Example WITH indentation keywords - result after Format Indentation (Ctr+I) - Indentation from ELSE, CASE, etc. is different to the case where no indentation was used (wrong?).
                                         
If 1     ;>
         ;<
   Else  ;>
         ;<
EndIf


Select a       ;>
               ;<
      Case 1   ;>
               ;<
      Case 2   ;>
               ;<
      Case 3   ;>
               ;<
      Default  ;>
               ;<
EndSelect

Author:  BarryG [ Sat Feb 08, 2020 8:18 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

No bug here? Indents like the below with a clean PureBasic install, when I type the first If/Else/EndiIf code exactly as you described it, and also after Ctrl+I.

I don't know what the ">" means, though? Did you type those as well? If I include them, I still don't get any indent problems either.

Did you change the indent settings from default?

Code:
If 1    ;
        ;
Else    ;
        ;
EndIf

Author:  PureLust [ Sat Feb 08, 2020 8:40 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

BarryG wrote:
I don't know what the ">" means, though? Did you type those as well? If I include them, I still don't get any indent problems either.
If I'm not wrong, ';>' and ';<' is PBs default to force an indentation.

In my case it's set to:
Code:
;>    before:  0    after:   2
;<    before:  0    after:  -2

Author:  Little John [ Sat Feb 08, 2020 9:28 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

Indentation has been working here (under Windows) as expected for a long time, and does also do so with version 5.72 beta 1.

Author:  PureLust [ Sat Feb 08, 2020 9:30 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

Little John wrote:
Indentation has been working here (under Windows) as expected for a long time, and does also do so with version 5.72 beta 1.
Have you tried to type the code from my example into your IDE (using your indentation-keywords)?
I encountered this behavior since first implementation of auto-align of Remarks.

In case it's triggered by a combination of Keywords - here is the full Indentation-part from my PureBasic.prefs for better bugtracking:
Code:
[Indentation]
IndentMode = 2
BackspaceUnindent = 1
NbKeywords = 64
Keyword_0 = ;->
Before_0 = 0
After_0 = 2
Keyword_1 = ;;+
Before_1 = 0
After_1 = 2
Keyword_2 = ;;-
Before_2 = -2
After_2 = 0
Keyword_3 = ;;<
Before_3 = -2
After_3 = 0
Keyword_4 = ;;>
Before_4 = 2
After_4 = 0
Keyword_5 = ;<
Before_5 = 0
After_5 = -2
Keyword_6 = ;>
Before_6 = 0
After_6 = 2
Keyword_7 = AddGadgetItem
Before_7 = -1
After_7 = 1
Keyword_8 = Case
Before_8 = -1
After_8 = 1
Keyword_9 = CloseGadgetList
Before_9 = -2
After_9 = 0
Keyword_10 = CompilerCase
Before_10 = -1
After_10 = 1
Keyword_11 = CompilerDefault
Before_11 = -1
After_11 = 1
Keyword_12 = CompilerElse
Before_12 = -1
After_12 = 1
Keyword_13 = CompilerElseIf
Before_13 = -1
After_13 = 1
Keyword_14 = CompilerEndIf
Before_14 = -1
After_14 = 0
Keyword_15 = CompilerEndSelect
Before_15 = -2
After_15 = 0
Keyword_16 = CompilerIf
Before_16 = 0
After_16 = 1
Keyword_17 = CompilerSelect
Before_17 = 0
After_17 = 2
Keyword_18 = ContainerGadget
Before_18 = 0
After_18 = 2
Keyword_19 = DataSection
Before_19 = 0
After_19 = 1
Keyword_20 = DeclareModule
Before_20 = 0
After_20 = 1
Keyword_21 = Default
Before_21 = -1
After_21 = 1
Keyword_22 = Else
Before_22 = -1
After_22 = 1
Keyword_23 = ElseIf
Before_23 = -1
After_23 = 1
Keyword_24 = EndDataSection
Before_24 = -1
After_24 = 0
Keyword_25 = EndDeclareModule
Before_25 = -1
After_25 = 0
Keyword_26 = EndEnumeration
Before_26 = -1
After_26 = 0
Keyword_27 = EndIf
Before_27 = -1
After_27 = 0
Keyword_28 = EndImport
Before_28 = -1
After_28 = 0
Keyword_29 = EndInterface
Before_29 = -1
After_29 = 0
Keyword_30 = EndMacro
Before_30 = -1
After_30 = 0
Keyword_31 = EndModule
Before_31 = -1
After_31 = 0
Keyword_32 = EndProcedure
Before_32 = -1
After_32 = 0
Keyword_33 = EndSelect
Before_33 = -2
After_33 = 0
Keyword_34 = EndStructure
Before_34 = -1
After_34 = 0
Keyword_35 = EndStructureUnion
Before_35 = -1
After_35 = 0
Keyword_36 = EndWith
Before_36 = -1
After_36 = 0
Keyword_37 = Enumeration
Before_37 = 0
After_37 = 1
Keyword_38 = EnumerationBinary
Before_38 = 0
After_38 = 1
Keyword_39 = EnumerationBinary
Before_39 = 0
After_39 = 1
Keyword_40 = For
Before_40 = 0
After_40 = 1
Keyword_41 = ForEach
Before_41 = 0
After_41 = 1
Keyword_42 = ForEver
Before_42 = -1
After_42 = 0
Keyword_43 = If
Before_43 = 0
After_43 = 1
Keyword_44 = Import
Before_44 = 0
After_44 = 1
Keyword_45 = ImportC
Before_45 = 0
After_45 = 1
Keyword_46 = Interface
Before_46 = 0
After_46 = 1
Keyword_47 = Macro
Before_47 = 0
After_47 = 1
Keyword_48 = Module
Before_48 = 0
After_48 = 1
Keyword_49 = Next
Before_49 = -1
After_49 = 0
Keyword_50 = PanelGadget
Before_50 = 0
After_50 = 2
Keyword_51 = Procedure
Before_51 = 0
After_51 = 1
Keyword_52 = ProcedureC
Before_52 = 0
After_52 = 1
Keyword_53 = ProcedureCDLL
Before_53 = 0
After_53 = 1
Keyword_54 = ProcedureDLL
Before_54 = 0
After_54 = 1
Keyword_55 = Repeat
Before_55 = 0
After_55 = 1
Keyword_56 = ScrollAreaGadget
Before_56 = 0
After_56 = 2
Keyword_57 = Select
Before_57 = 0
After_57 = 2
Keyword_58 = Structure
Before_58 = 0
After_58 = 1
Keyword_59 = StructureUnion
Before_59 = 0
After_59 = 1
Keyword_60 = Until
Before_60 = -1
After_60 = 0
Keyword_61 = Wend
Before_61 = -1
After_61 = 0
Keyword_62 = While
Before_62 = 0
After_62 = 1
Keyword_63 = With
Before_63 = 0
After_63 = 1

Author:  Little John [ Sat Feb 08, 2020 9:41 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

PureLust wrote:
Have you tried to type code from my example (using your indentation-keywords)?

Yes, I'm using some own keywords for indentation.

The problem is probably that neither ";>" nor ";<" is a keyword (and I can't see where it is documented that it's something default in PB either).

Author:  BarryG [ Sat Feb 08, 2020 9:46 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

PureLust wrote:
Code:
Keyword_0 = ;->
Before_0 = 0
After_0 = 2
Keyword_1 = ;;+
Before_1 = 0
After_1 = 2
Keyword_2 = ;;-
Before_2 = -2
After_2 = 0
Keyword_3 = ;;<
Before_3 = -2
After_3 = 0
Keyword_4 = ;;>
Before_4 = 2
After_4 = 0
Keyword_5 = ;<
Before_5 = 0
After_5 = -2
Keyword_6 = ;>
Before_6 = 0
After_6 = 2

None of those are in a clean PureBasic install's "Prefs" file.

Author:  PureLust [ Sat Feb 08, 2020 9:47 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

Little John wrote:
The problem is probably that neither ";>" nor ";<" is a keyword (and I can't see where it is documented that it's something default in PB either).

I'm not sure if ';>' and ';<' are set by default (because I'm using these for soooo long - oh boy, am I old :? ), but I'm sure there are some default keywords defined for indentation.
Did you had a look in Preferences => Editor => Indentation (Einstellungen => Editor => Einr├╝ckung)?

Author:  BarryG [ Sat Feb 08, 2020 9:48 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

PureLust wrote:
I'm sure there are default keywords defined for indentation.

They're not. See my post above. You must've added them manually at some stage.

Author:  Little John [ Sat Feb 08, 2020 10:01 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

In PureBasic, a keyword begins with one of the letters A-Z or a-z and consists only of those letters and the digits 0-9 and the character '_'.

Little John wrote:
The problem is probably that neither ";>" nor ";<" is a keyword

Author:  PureLust [ Sat Feb 08, 2020 10:03 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

BarryG wrote:
They're not. See my post above. You must've added them manually at some stage.
BarryG wrote:
None of those are in a clean PureBasic install's "Prefs" file.
Hmmpf ... did thought that there was at least one pair of Keywords as default. :?

I use them quite a lot to force indentations to get better readability of my code or to let some important parts of the code stand out.
I also use similar Keywords for folding ( ';{' or ';}' ) to be able to fold on remarks, which still works fine.

Since implementation of auto remark-alignment it's really frustrating sometimes, how the IDE messes up your code and formats it in a way you don't want it to be formatted. :(
Would be great to have it as an option, so one can switch it off.

Author:  Little John [ Sat Feb 08, 2020 10:40 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

PureLust wrote:
Did you had a look in Preferences => Editor => Indentation (Einstellungen => Editor => Einr├╝ckung)?
Yes, I'm aware of that.
Little John wrote:
Yes, I'm using some own keywords for indentation.
For defining them, of course I used that dialog.

PureLust wrote:
Sometimes it's really frustrating that the IDE does not handle these kind of Keywords right, since implementing of auto remark-alignment. :(

The IDE does everything right in this respect.
The character combinations that you use (such as ";->", ";;+", ";;-" etc.) are not keywords -- did I mention that already? :mrgreen: And since they all start with ';', they are treated as comments.

No bug here at all.

Author:  PureLust [ Sat Feb 08, 2020 11:07 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

Little John wrote:
Yes, I'm using some own keywords for indentation.
Interesting ... do you have defined anything, rather then ordinary PB commands, so they can be used anytime and anywhere in the code?

Using comments (";"-combinations) as indentation- or folding-keywords is very handy, because they do not irritate the compiler and you can indent or fold any time and even within a comment (like I use them for).

And as you might know ';-' is also a special and native ";"-combination. It's very handy to set up ";->" as an indentation keyword, to show the comment in Procedure-Window and also indent to let the line stand out in your code. :wink:

Author:  #NULL [ Sat Feb 08, 2020 11:21 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

I think it was JaPBe that began to supporting ;> and since then for me too it feels like default even in the PB-IDE. :)

Author:  #NULL [ Sat Feb 08, 2020 11:31 am ]
Post subject:  Re: [5.72-B1] Indentation still buggy

Maybe you should define what result you are expecting. In any case I think 'format code' shouldn't have a different result than what auto-indentation did in the first place (likewise, formatting commented-out code indents it in a wrong way).

Page 1 of 2 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/