voithos / swiftcode

Multiplayer, interactive, realtime typing speed game

Home Page:https://swiftcode.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tabs in sources

scriptin opened this issue · comments

I've found some GLSL code containing tabs in assignment statement after = (for vertical alignment, I guess). Browser switches between interactive elements on the page when I press tab.

When the code is inserted into the DOM, the highlighting library is supposed to convert tabs into spaces. I'll have to look, but I think what's happening is that SwiftCODE isn't converting tabs to spaces when first loading exercises (from the admin interface). This causes the tab to stay in the code that the user needs to type, but there's no way for them to input that.

There's 2 things that we could do: 1) convert all tabs to spaces, always. This would mean that players would have to type out a bunch of spaces for alignment code. Or, 2) add the ability to type a tab character, most likely not just for when there's an actual tab character in the exercise code, but also when there are e.g. 4 spaces in a row.

@voithos Those two points do not contradict each other: tabs can be converted AND tab may be used to insert 4 spaces. I think tabs should be converted because they can confuse a player when it happens that a tab fills less than its' normal width. You know, when it appears after some text and shrinks like that:

    def // 1 tab before 'def'
abc def // 1 tab between 'abc' and 'def', shrinked to 1 space due to alignment

Also, there are some examples which already have a bunch of spaces for vertical alignment, so players already have to type lots of spaces sometimes. I don't consider it a problem, because that's what I actually do when I align my code vertically.

So, I think 1st point is a must, while 2nd is optional, but would be nice to have.

@scriptin Good point - I think that's the cleanest way to go about it. I'll add that to the implementation list.