Closed dannypsnl closed 1 year ago
I don't know if someone uses tab for indentation. I always use "convert tab to spaces" personally. We can respect these arguments:
trimTrailingWhitespace
insertFinalNewline
trimFinalNewlines
I also don't use tabs and always convert to spaces... The Racket style guide also says don't use tabs. (Perhaps someone still uses tabs anyway, but I'm guessing that's quite rare in the Racket ecosystem.)
I now understand the purpose of tabSize
and insertSpaces
. The formatting function always uses space indentation.
If someone use tab indentation in editor, it will look weird.
Based on the Racket style guide, maybe we can replace all tabs with spaces before formatting?
Yes, that would be great due to the style
So we ignore the options tabSize
and insertSpaces
, and always use replace tabs with spaces instead?
Yes, at least we can make a that first, if anyone wants different behavior, then make the implementation be the default setup & provides others
No, It's not easy to do.
The formatting function works for a range of lines.
For example, it need to format from line start
to line end
(exclusive).
Then if line start - 1
uses tab indentation, line start
will always get wrong indent from compute-racket-amount-to-indent which calls racket-amount-to-indent as it doesn't know the tab size.
We cannot make racket-amount-to-indent
to know the really tab size, as it seems hardcoded the tab size to 8.
If we replace \t
with 8 spaces of line first?
Good suggestion! It feels dirty but it works.
Link: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#formattingOptions