bugGNU Octave - Bugs: bug #60649, Incorrect indentation for...

 
 

bug #60649: Incorrect indentation for endswitch and otherwise keywords in GUI editor

Submitted by:  PIERRE LABRECHE <pierre5018>
Submitted on:  Thu 20 May 2021 05:13:02 PM UTC  
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  PIERRE LABRECHE Open/Closed:  Closed
Release:  6.2.0 Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Fri 28 May 2021 09:23:30 PM UTC, comment #8: 

This issue is fixed in the stable branch with cset http://hg.savannah.gnu.org/hgweb/octave/rev/0e888d2f79b7

Torsten Lilge <ttl>
Project Member
Sat 22 May 2021 02:10:04 PM UTC, comment #7: 

IMHO "as you type" means that you just type "case 2" without already fixing its indentation manually, i.e.

switch a
  case 1
    b = 0
    case 2<return>

When using the "Indent" action on selected code, I can confirm the wrong indentation of "otherwise".

Torsten Lilge <ttl>
Project Member
Sat 22 May 2021 01:50:23 PM UTC, comment #6: 

Indenting interactively on the go, as you type:

Enter this code manually, and stay on the last line.

switch a
  case 1
    b = 0
  case 2

Then type "carriage return".  "case 2" becomes mis-aligned.

Indenting a selected section of code.
procedure : Select text. Right-click, choose the menu item Format, Indent.

The bulk indenting of a section of code containing switch statements is messy.

PIERRE LABRECHE <pierre5018>
Sat 22 May 2021 08:46:06 AM UTC, comment #5: 

What exactly do you mean by "interactive editing" or what are the precise steps to get the issue shown in comment #44.

On my Debian system, everything works fine including indentation of "otherwise". The only issue I am seeing is that "endswitch" or "end" is not correctly indented (but differently):

switch a
  case 1
    b = 0
  case 2
    b = 5
  otherwise
    b = -1
  end

switch a
  case 1
    b = 0
  case 2
    b = 5
  otherwise
    b = -1
    endswitch

However, the auto closing feature sets the correct indentation.

Torsten Lilge <ttl>
Project Member
Sat 22 May 2021 12:57:28 AM UTC, comment #4: 

Don't forget to also fix interactive editing. When entering the individual case clauses, indentation is also messy , even before typing an otherwise clause.

For example, the editor auto indents like this (badly):

switch r
  case c
    do_this
case d
...

In the above, "case d" is automatically misaligned with "case c" above.

PIERRE LABRECHE <pierre5018>
Fri 21 May 2021 10:33:38 PM UTC, comment #3: 

The endswitch is also messed up.

PIERRE LABRECHE <pierre5018>
Fri 21 May 2021 10:27:52 PM UTC, comment #2: 

Should the Summary be more specific that it is the "otherwise" keyword which is not indented correctly?

It looks like the "switch" and "case" statements are correct up until that point.

Rik <rik5>
Project Administrator
Fri 21 May 2021 11:41:45 AM UTC, comment #1: 

Confirmed.
As I figured this to be a minor annoyance I never bothered to report it but it's a good thing you did.

Philip Nienhuis <philipnienhuis>
Project Member
Thu 20 May 2021 05:13:02 PM UTC, original submission:  

Point #1:
A switch statement should be indented one level, all cases and otherwise clause indented at the same level.

The current auto indentation gives:
    switch r
      case a
        do_a
      case b
        do_b
      case c
        do_c
    otherwise
      do_otherwise
  endswitch

-verbatim-

The desired auto indentation is:

    switch r
      case a
        do_a
      case b
        do_b
      case c
        do_c
      otherwise
        do_otherwise
    endswitch

Point #2:
As the user types "on the go" switch statements from scratch, the indentation is messy.

PIERRE LABRECHE <pierre5018>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pierre5018 (Submitted the item)
  • -email is unavailable- added by pierre5018
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-05-28 ttl StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2021-05-21 rik5 SummaryIncorrect indentation for switch statement , cases, and otherwise clause => Incorrect indentation for endswitch and otherwise keywords in GUI editor
    2021-05-21 philipnienhuis StatusNone => Confirmed
    2021-05-20 pierre5018 Carbon-Copy- => Added pierrelabreche@gmail.com

    Back to the top


    Powered by Savane 3.7