Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Auto Indent" doesn't work for .livecodescript files #16

Closed
peter-b opened this issue Oct 23, 2015 · 5 comments
Closed

"Auto Indent" doesn't work for .livecodescript files #16

peter-b opened this issue Oct 23, 2015 · 5 comments
Labels

Comments

@peter-b
Copy link
Contributor

peter-b commented Oct 23, 2015

For LiveCode Builder source code, the "Edit->Auto Indent" command ("Editor: Auto Indent" via the command palette) properly re-indents source code, including if/repeat/handler etc.

This doesn't seem to work properly for LiveCode Script source code (.livecodescript files).

@peter-b peter-b added the bug label Oct 23, 2015
@montegoulding
Copy link
Member

I've worked this out.. It seems you can't have two settings blocks for the same grammars. I'll merge them. Will need to submit one PR for this and #18 now. I'm also looking at how to improve with switch indenting. At the moment break decreases indent so break and case are at the same indent level. With case indenting it means when you want continuation you end up with case indenting again.. not good.

I've tried case both increasing and decreasing and it works OK apart from the fact that case and switch are at the same indent. Not ideal but better than the increasing indentation with continuation bug. What are your thoughts? What we really need is a way to force the precedence of the switch increase in indent over the case decrease, however, I'm not sure if that is possible. I'm off to investigate some other languages to see how they handle it.

@montegoulding
Copy link
Member

I've also added support for default which was missing. After thinking on the switch handling I don't think (unless I'm missing something) that we can do much better than case and default being both indent increasers and decreasers. If they aren't then then we rely on break too much to decrease our indent which is clearly unacceptable when you consider continuation or the fact that break is redundant on the last case.

So... I'm going to run with my changes. The quirk will be that switch, case and default are on the same indent but that compromise is better than the bugs of cases with continuation indenting again and ending the control structure not returning to the correct indent level. Even if we can think of a way to indent the cases the end switch wouldn't return us correctly to the right indent so I don't think there's any other options unless there's a way to script the behavior...

montegoulding pushed a commit to montegoulding/atom-language-livecode that referenced this issue Oct 24, 2015
Editor settings for iRev and LCS were being clobbered by autocomplete.
The issue was introduced when iRev was added as a scope for the
the autocomplete settings. This commit also resolves some issues with
switch indenting, variable and constant capturing.
@montegoulding
Copy link
Member

One extra thing I'll note about switch indenting is that after reviewing a number of other languages I have found that they don't indent cases so what they do is the equivalent of this:

switch thing
   case thing1
   /* code */
   break
   case thing2
   /* code */
   break
end switch

I find the lack of indentation on the cases unhelpful. What I have done will result in this which I prefer:

switch thing
case thing1
   /* code */
   break
case thing2
    /* code */
   break
end switch

It does not appear to be possible to implement both indentation after switch and after case AND fix the bugs I found and outlined earlier. As seen here:

switch thing
   case thing1
      /* code */
      case thing2
          /* code */
         break
      end switch

and here:

switch thing
   case thing1
      /* code */
      break
   case thing2
      /* code */
   end switch

@peter-b
Copy link
Contributor Author

peter-b commented Oct 24, 2015

@montegoulding What does Atom's C language mode do? I think the best thing to do is to copy that. If it does what you describe, then that sounds like a win to me. I agree that what you've done looks the best out of the options that you've described...

@peter-b peter-b added this to the v0.6.1 milestone Oct 24, 2015
@montegoulding
Copy link
Member

I looked at c, php and JavaScript. All have no indentation for case. I'd rather not follow the crowd if we can do better. You can obviously manually indent though. I wonder what atom would need for proper support... I guess some way to link the indent of the first block to subsequent blocks that should have that level???

@peter-b peter-b modified the milestone: v0.6.1 Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants