I just sat thinking some more about this. What would N be?
N would depend on the tab_width, but I am pretty sure you meant this
For me it would be 4, but I should not make such assumptions. Therefore, I think it's better people just always post spaces instead of tabs. What do you think?
I understand your point (I also want to avoid making such assumptions whenever possible), however there are several thing to consider here:
Posting only spaces instead of tabs is ok, but that won't fix the original problem. You can't avoid that people will upload code that contains actual tabs, not spaces.
- Even if I make that the default option in TESH 2.0 (which I will), people might just change that option and use tabs anyway.
- Or consider Wurst script, which uses Eclipse. Its editor can also be configured to use actual tabs instead of spaces.
- Same applies for custom highlighting tools like this notepad++ extension.
So there will always be the possiblity that users upload code containing tabs. Whenever that happens and you convert their tabs to spaces, you have to choose some tab_width. The only way to avoid this would be to not convert tabs and display them as tabs - but even then you would have to define the
visual tab_width, which will lead to more or less the same result, requiring the same assumptions. There is
no way around this.
Remember that this is also nothing new, it has always been like that: the tab_width in BB code (since there, tabs are not converted to spaces) has always been 4. In the old version of the forum, this was the standard tab_width as well.
Therefore I would either display tabs as they are (with a tab_width of 4) or convert them by taking their width into account (again using an effective tab_width of 4).
Why 4? There are several good reasons for that:
- The first I already mentioned, it has always been like that in this forum, so I see no need to change this.
- A tab_width of 4 has also always been the (unchangable) tab_width of the TESH (also in the old TESH by SFilip)... so its like that for almost 10 years now in vJass coding.
- Also, Blizzard uses a tab_width of 4 in their Jass code (compare common.j or Blizzard.j), which was also one of the reasons why this tab width was chosen for TESH.
- Most resources in both the Spell section and the Jass section that contain (v)Jass code, use a tab width of 4.
- In the JPAG (JASS Proper Application Guide, coding conventions for code submissions), there was once a discussion on this topic and the consensus was (more or less) that a tab width of 4 is the most "reasonable" choice. Arguments were similar to the ones listed here.
- Other sites with focus on displaying code like Stackoverflow also do it like that: tabs are converted to spaces assuming a tab width of 4.
On the other hand, the only real reason to use a tab width different than 4 would be personal preferences. Which is a valid point, but this point also applies to a tab width of 4 (I would also assume that the majority of people prefers a tab width of 4 due to the points mentioned above).
So, my suggestion would be: Convert tabs to spaces, taking their actual length into account (like posted above), with assuming a tab width of 4.
No need to make things more complicated than they are, and this approach will basically always work without breaking indentation.