Consistent "Code needs to line up"


#1

I have searched the forums, did not see a thread, so starting this one.

I started to see a lot of errors start to show up in the editor. It would keep telling me: “Code needs to line up”.
I would look at the code, and everything lined up, all my indents and everything were perfect.

Then I saw it, it was a difference between spaces “.” and tabs “‣”. If you have spaces indenting a line, and the next line is using tabs, it will not detect them as being at the same indentation. However, if you take your code to an external editor, and convert all the tabs to spaces or all the spaces to tabs, you are in good shape - no editor errors.

The problem is that sometimes if you hit the tab key - you get a tab character, other times you will get the 4 spaces. Not consistent.

I am for using tabs, spaces are harder to count and see if you are off by a space or not.


#2

Hey Greg, we’re tracking that bug here: https://github.com/codecombat/codecombat/issues/1127

For simplicity’s sake, instead of allowing configuration of whether you use tabs or spaces, we are just insisting on spaces, because there’s a lot of tooling that we’d need to update to also support tabs. The ACE editor does support smart tabs and visualizing whitespace, but I think the whitespace visualization is off by default–maybe I’ll enable that to make it easier to see the whitespace.


#3

Ugh! Spaces! :frowning:
Oh well… I guess I will write in another window and then paste it in. :stuck_out_tongue_winking_eye:


#4

I haven’t had any issues using tabs on my end. Maybe I just always use tab…


#5

@dwhittaker I thing I did notice was that if you hit tab in the built-in editor, it will not produce a tab, instead will immediate substitute 4 spaces. Are you seeing this? Are you seeing 4 dots or 1 arrow?

If you open up a text editor and use all tabs and then copy and paste into the editor, the tabs -vs- spaces are extremely apparent.


#6

Yeah, I just use the editor. I don’t see dots and arrows, is that something I can turn on? But I do notice that they are treated as 4 spaces.


#7

It’s currently configurable in the editor configuration options inside the game menu:

We may end up simplifying and removing all of those options and just defaulting things, to keep it simple.


#8

Nick and team…
Thank you very much for all the improvements you have made to the editor. Things seem to be working much better. I am still hoping for tabs, but spaces work now, and it does not seem to mix the two anymore.

Still would love floating windows or tabs to see references, classes information, etc… and allow for a longer editor window!

Cheers!