microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.93k stars 12.47k forks source link

Support for tabs in language service formatter. #2306

Open hachre opened 9 years ago

hachre commented 9 years ago

The formatter described in the link below currently doesn't seem to offer a way to indent by using tabs. https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#pretty-printer-using-the-ls-formatter

Could that be added? Thanks!

basarat commented 9 years ago

ConvertTabsToSpaces ? I hate tabs btw.

hachre commented 9 years ago

I'd like something like ConvertSpacesToTabs. Right now if you give it a space indented input there is no way to get it changed to tabs like there is with a tab indented input.

Why do you hate tabs?

loucyx commented 9 years ago

+1. The Sublime Text plugin uses this to format the TS code, but I use tabs in my project, so it will be nice if you let us set if we want spaces (2 or 4) or tabs in the format (I'm not even asking to do so on the output, but it also would be nice).

basarat commented 9 years ago

Why do you hate tabs

https://www.google.com.au/search?q=tabs+vs.+spaces&safe=off&source=lnms&tbm=isch&sa=X&ei=A_ooVfKHH8KwmAX4jYCoAw&ved=0CAcQ_AUoAQ&biw=2048&bih=1071&dpr=1.25

I don't have a good answer :rose:

DanielRosenwasser commented 9 years ago

Why do you hate tabs?

Why don't you love spaces? :wink:

hachre commented 9 years ago

@DanielRosenwasser Beause I like to have control over the indendation depth when I view files and because I find it easier to make a "single space" mistake in indendation than a "single tab" mistake because the differene is way more obvious. It's just a preference ;)

loucyx commented 9 years ago

@DanielRosenwasser because, in my opinion, spaces are "dirty". Tabs allow more control about indentation, are characters designed to indent, and are only one, instead of 2 or 4 like spaces...

Besides, the thing here is not to have one or the other, the thing is to have the option to choose.

loucyx commented 9 years ago

I've just done a pull request adding a --indentStyle parameter in order to address issues like this one: #2768

hachre commented 9 years ago

Thanks @lucasmciruzzi

mhegazy commented 9 years ago

@lucasmciruzzi, i do not see how #2768 is related to this issue. your change targets the generated js, and not the language service formatting for typescript files.