bugGNU Octave - Bugs: bug #55276, Indent code does not indent...

 
 

bug #55276: Indent code does not indent "else" properly

Submitter:  Avinoam Kalma <avinoam>
Submitted:  Mon 24 Dec 2018 09:27:45 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  lostbard
Originator Name:  Avinoam Open/Closed:  * Closed
Release:  * 5.0.1 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 27 Jan 2019 04:31:19 AM UTC, comment #14: 

Marking as fixed after Andrew's testing.  Closing report.

Rik <rik5>
Group administrator
Sat 26 Jan 2019 11:40:49 PM UTC, comment #13: 

Works for me. Thanks!

Andrew Janke <apjanke>
Sat 26 Jan 2019 08:52:57 PM UTC, comment #12: 

I pushed up  another changeset that gets case/otherwise indenting correctly for me

John Donoghue <lostbard>
Group Member
Tue 22 Jan 2019 11:22:03 AM UTC, comment #11: 

It will be a little harder than the else was but i hadnt gotten a chance to get back to it, so if someone else beats me to it, thats fine

I believe it needs to ident the case (and otherwise) statement if the code line was case statemnt, leave the line at the current indentation if the last statement was a case statement otherwise set the indent back one


John Donoghue <lostbard>
Group Member
Tue 22 Jan 2019 05:34:30 AM UTC, comment #10: 

Seems like the original issue has been fixed.  Is it simple enough to extend the fix to the case statement, or should a new bug report be opened?

Rik <rik5>
Group administrator
Sat 12 Jan 2019 09:38:08 PM UTC, comment #9: 


> the case, case ident isnt valid code is, it? as there should be a statement after the case, before the next case.


I think it's valid, just useless. Each case is a no-op there. But the same thing happens if you add code:


function foo(x)
  switch x
    case 1
      y = 1;
      case 2
        y = 2;
        case 3
          y = 3;
          case 4
            y = 4;
  end
end


Andrew Janke <apjanke>
Sat 12 Jan 2019 12:47:04 PM UTC, comment #8: 

the case, case ident isnt valid code is, it? as there should be a statement after the case, before the next case.

The indent from the switch to the case is the issue, and is because the indent code if faily simplistic, and and effectively indents the next line when the line above was a key word

John Donoghue <lostbard>
Group Member
Sat 12 Jan 2019 07:27:06 AM UTC, comment #7: 

I'm having a similar issue with "switch".

If I just type it out in the editor, it indents it like this:


function foo(x)
  switch x
    case 1
      case 2
        case 3
          case 4
            case 5
              otherwise
  end
end


Could a similar fix be used for switch?

Andrew Janke <apjanke>
Mon 07 Jan 2019 03:06:22 PM UTC, comment #6: 
John Donoghue <lostbard>
Group Member
Mon 31 Dec 2018 06:51:27 AM UTC, comment #5: 

This patch fix thje problem for me

Avinoam Kalma <avinoam>
Group Member
Sat 29 Dec 2018 02:25:36 PM UTC, comment #4: 

Patch attached

(file #45768)

John Donoghue <lostbard>
Group Member
Sat 29 Dec 2018 07:51:12 AM UTC, comment #3: 

elseif behaves the same as else and doesnt comment correctly

John Donoghue <lostbard>
Group Member
Fri 28 Dec 2018 10:28:08 PM UTC, comment #2: 

Related, assuming that the issue is in libgui/src/m-editor/octave-qscintilla.cc, line 568, is looking for endword of 'end_unwind_protext', but should be 'end_unwind_protect'

John Donoghue <lostbard>
Group Member
Mon 24 Dec 2018 09:31:19 PM UTC, comment #1: 

Sorry. Again:

Example:

See the following simple code:


function aa = fun (arg1)
  if (nargin == 0)
    arg1 = 0;
  else
    arg2 = 5;
  endif
endfunction


"else" is not indented correctly.

If I select the whole code and perform "Indent Code"
(shortkey defined by Preferences -> Shortcuts -> Editor -> Edit Menu -> Indent Code)
I get:


function aa = fun (arg1)
  if (nargin == 0)
    arg1 = 0;
    else
      arg3 = 5;
    endif
  endfunction


Avinoam Kalma <avinoam>
Group Member
Mon 24 Dec 2018 09:27:45 PM UTC, original submission:  


Example:

See the following simple code:


function aa = fun (arg1)
  if (nargin == 0)
    arg1 = 0;
  else
    arg2 = 5;
  endif
endfunction


If I select the whole code and perform "Indent Code"
(shortkey defined by Preferences -> Shortcuts -> Editor -> Edit Menu -> Indent Code)
I get:

+verbatim+
function aa = fun (arg1)
  if (nargin == 0)
    arg1 = 0;
    else
      arg3 = 5;
    endif
  endfunction

 

Avinoam Kalma <avinoam>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #45768:  format.patch added by lostbard (3KiB - text/x-patch)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by avinoam
  • -email is unavailable- added by avinoam (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-04 siko1056 Dependencies- bugs #56218 is dependent
    2019-01-27 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-01-24 mtmiller Release5.0.0 5.0.1
    2019-01-07 lostbard StatusPatch Reviewed Ready For Test
        Assigned toNone lostbard
    2019-01-03 avinoam StatusPatch Submitted Patch Reviewed
    2018-12-29 lostbard Attached File- Added format.patch, #45768
        StatusNone Patch Submitted
    2018-12-24 avinoam Carbon-Copy- Added ttl
    2018-12-24 avinoam Carbon-CopyRemoved torsten -
    2018-12-24 avinoam Carbon-Copy- Added torsten

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code