BUG, or maybe just a feature request....

I have noticed that if you define a function as a property of an object, the resulting “end” doesn’t line up correctly.

example:

[lua]function new(kind)
if(kind == 1) then
foo = display.newImageRect(“foo.png”, 16, 16);
foo.collision = function(self, e)
end
end
end[/lua]

Notice the “end” for the end of the foo.collision = function… line is aligned with the “end” for the enclosing if statement.

Can we get it so that the “end” for the foo.collision = function… line aligns itself to the beginning of the foo.collision line?

The way it is makes it very difficult to see if everything is ended correctly, plus it makes a visual mess of my code :slight_smile: [import]uid: 5317 topic_id: 10997 reply_id: 310997[/import]

I’ll poke at that – I know the indenting can get screwed up at times. It works by parsing things with regular expressions and I am NOT skilled at regex. :slight_smile:

Jay
[import]uid: 9440 topic_id: 10997 reply_id: 40036[/import]

I understand. I found a pdf somewhere that was the be all and end all of regex books.

Still haven’t had a need to look into it deeply, thank god. Some people are regex monsters, I personally hate it.

Just as a completely useless thought, perhaps, much like auto-complete of brackets works, you could, maybe, after you type in any of the keywords that require an end with them, after the next press of enter, automagically add an “end” at the same indentation level as the appropriate keyword…

perhaps? [import]uid: 5317 topic_id: 10997 reply_id: 40044[/import]

I’m looking at something like that. In 2.2.5 if you press Shift-Return it adds a adds a carriage return and an “end” – but it’s not indented so it’s only part of the way there. But, it’ll work at some point soon (I think). :slight_smile:

As far as it magically adding it, I don’t think I’d do that unless I make it a preference and if I do that I might need to rethink whether Prefs is set up correctly – if I keep adding lots of little things it could get way too crowded too fast. So I’ll probably (at least initially) keep it as Shift-Enter (that’s what my desktop dev environment does, so I’m used to that).

Jay
[import]uid: 9440 topic_id: 10997 reply_id: 40046[/import]

I would be perfectly happy with shift-enter.

Maybe even easier, is an option to disable the auto indenting. By that I mean when I type “end” it tries to figure out what the needed indentation level is. If we could disable that, I would be happy.

My real issue is once CPM decides what level the “end” needs to be at, I can’t change it. If I could just TAB it over where it belongs, I’d be happy. [import]uid: 5317 topic_id: 10997 reply_id: 40047[/import]

You can turn off auto-indenting in the Editor tab of Preferences.

Also, in those lines that get confused, if you delete it back to the previous line and then hit Return it will indent correctly. (If you get what I mean.) Not a good solution, but it’s at least a workaround for now.

Jay [import]uid: 9440 topic_id: 10997 reply_id: 40052[/import]

The workaround, works around the issue to my satisfaction. [import]uid: 5317 topic_id: 10997 reply_id: 40079[/import]