This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Engineer's profile picture

Re-indent

Started by Engineer, 06 May 2013 - 10:20 AM
Engineer #1
Posted 06 May 2013 - 12:20 PM
RE-INDENT


Hello people of this lovely forum!

It is finally here!
A full functioning re-indenter where we all waited for!
This iterates through your code, and tries to make a decent indentation. However, when the code is incomplete,
for example an end is missing, thi will fail to make a proper indentation.
But that can you even help debugging, when you see a double end with the same indentation, you know you have too much end's or too few.

This will run on both computers; advanced and normal!

This will look like it when you re-indent on an advanced computer:
Spoiler

And it will look like this on a normal one:
Spoiler
We might consider a GUI on normal computers.

If you find any bug or issue, please report it in this topic or in the dedicated github.

Download it here:

pastebin get EqGh5VFM reindent

We would love some feedback from you guys!
Thanks for reading!

~GravityScore and Engineer
SadKingBilly #2
Posted 06 May 2013 - 12:48 PM
Took me a while to figure out how to adjust the tab width. :lol:/>

I don't have any use for it, really, but great work! ^_^/>
superaxander #3
Posted 06 May 2013 - 01:15 PM
Great work I followed it from the beginning on github!
Engineer #4
Posted 06 May 2013 - 02:02 PM
Took me a while to figure out how to adjust the tab width. :lol:/>

I don't have any use for it, really, but great work! ^_^/>
Thanks! :D/>


Great work I followed it from the beginning on github!

You know that I was presuming that already?
That is because you gave a tip on of my commits, not in the re-indent git though :P/>
Smiley43210 #5
Posted 06 May 2013 - 02:30 PM
Cool! Does it correct code with too much indentation? And it doesn't indent one line statements, right?
Example:
if a = 1 then print("Ok") end

And I am so using this to convert all my programs with 4 space indents (my old style) to 2 space indents.
Engineer #6
Posted 06 May 2013 - 02:36 PM
Cool! Does it correct code with too much indentation? And it doesn't indent one line statements, right?
Example:
if a = 1 then print("Ok") end

And I am so using this to convert all my programs with 4 space indents (my old style) to 2 space indents.

We read the file line by line and remove the whitespace around it, so yes! However, comments are not indented but the whitespace still gets removed. We might fix this later. This comes from me, Im not sure how Grav thinks about it. But I have kind of an idea how to fix that! :D/>

^ Counts also for strings, multiline or not.

No it does not indent one-line statements. Glad you have an use for this :P/>
Smiley43210 #7
Posted 06 May 2013 - 02:52 PM
Awesome! One more thing: what about blank lines? I normally like to have no whitespace after lines and on blank lines (which still counts as "after" it cause there's nothing on it)

Ooh, and nice new shiny avatar :D/>
Reminds me of the Eclipse logo, but way better.
Engineer #8
Posted 06 May 2013 - 03:27 PM
I think it leaves just the blank space right there. Not sure, never tested that :P/>

And thanks!

Currently working on the comment-string thingie I mentioned in my last reply.
Engineer #9
Posted 06 May 2013 - 03:43 PM
Pushed new update! Now multiline strings and comments dont get touched in any way!
Example (spoilers here I come!):

This is the testing code:
Spoiler

--[[
      test 
          this
    is 
        not
 affected ]]

Previous update:
Spoiler

--[[
test
this
is
not
affected ]]

Current update:
Spoiler

--[[
      test 
          this
    is 
        not
 affected ]]
Smiley43210 #10
Posted 06 May 2013 - 05:44 PM
Bug: If a one line statement is mixed with another one line statement, and you only end the inner ones in that line, the next line will be de-indented. Bad explanation, I know. Try this: run reindent on itself. Then look in the first function (centerPrint). That's an example.

Screenshot of the result. The else should be indented, as well as the code within it.
Engineer #11
Posted 06 May 2013 - 05:59 PM
Added to the issues of the github.

Thank you for reportin it smiley! :)/>
I currently cant reach my desktop due to some personal issues Im having. A fix will be soon released by GravityScore or me.

Check the git for the most recent version. (not now, in a few days/hours)
oeed #12
Posted 06 May 2013 - 06:09 PM
This sounds great, I've been looking for something that actually works for ages! I've tried it out it works almost perfectly.

However, indentation on tables doesn't work. This is something that would be very useful for me as I use tables constantly.
Dlcruz129 #13
Posted 06 May 2013 - 10:40 PM
This should be in LuaIDE!
oeed #14
Posted 06 May 2013 - 10:41 PM
This should be in LuaIDE!

Yes!!!!
theoriginalbit #15
Posted 06 May 2013 - 10:54 PM
This should be in LuaIDE!
There is one in LuaIDE.
Dlcruz129 #16
Posted 06 May 2013 - 10:57 PM
This should be in LuaIDE!
There is one in LuaIDE.

There's auto-indent, but I don't think there's a re-indent.
superaxander #17
Posted 07 May 2013 - 12:54 AM
Well gravity is one the creators of this so it would be easy for him to implement it.
Smiley43210 #18
Posted 07 May 2013 - 02:10 AM
This should be in LuaIDE!
There is one in LuaIDE.

There's auto-indent, but I don't think there's a re-indent.
No, theres a reindent. Its under the Functions menu :P/>. Perhaps you didn't try updating. And also, he implied he added it on the program page, in the credits section ("- Engineer, for the re-indent function").
GravityScore #19
Posted 07 May 2013 - 03:42 AM
Yes, I added this to LuaIDE just after this was released :P/> Try updating if you don't see it, it's under the functions menu.

And also, implied he added it on the program page, in the credits section ("- Engineer, for the re-indent function").
I probably should add it to the features section hey :P/>
Dlcruz129 #20
Posted 07 May 2013 - 10:18 AM
Yes, I added this to LuaIDE just after this was released :P/>/> Try updating if you don't see it, it's under the functions menu.

And also, implied he added it on the program page, in the credits section ("- Engineer, for the re-indent function").
I probably should add it to the features section hey :P/>/>

Ah, ok. Hadn't used LuaIDE since a couple of days ago.
coaster3000 #21
Posted 22 May 2013 - 09:27 PM
I added a pull request to your github for a yield system to keep CC happy with large files being re-indented..


Pull Request

Love this program by the way. The changes I added were very essential for me.. My files are too large..