Julia-vscode: Add parenthesis for range arguments in the formatter

Created on 1 Aug 2017  路  6Comments  路  Source: julia-vscode/julia-vscode

Right now the formatter changes 1+n:5 to 1 + n:5 which is confusing. Perhaps (1 + n):5 could be used instead?

enhancement

All 6 comments

Hm, I'm not sure we want the formatter to ever add things like parenthesis, I think it should probably stay with adding and removing whitespaces and line breaks. But maybe it just shouldn't add whitespaces in range expressions?

I'd quite like this as an opt-in configurable option, the inverse relation between whites space distance and precedence confuses me

I tend to write the arithmetic with no spaces and no parens in this situation, but realize some people find that objectionable. The parenthesized form is ok as well, but the wide spaced non-parens form is actively misleading in appearance.

So I think the formatter should then a) remove whitespaces in range expressions that don't use parenthesis, and b) add whitespaces in range expressions that do use parenthesis. But I feel pretty strongly that the formatter should never add or remove parenthesis, that to me is more of a refactoring than a formatting change.

if there's whitespace in an expression on either side, I tend to think it's more readable to also add spaces around the colon

Closing this, if there's any further interest continue it at https://github.com/zacln/documentformat.jl

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jlperla picture jlperla  路  25Comments

fplk picture fplk  路  17Comments

chrisbrahms picture chrisbrahms  路  26Comments

barche picture barche  路  38Comments

davidanthoff picture davidanthoff  路  25Comments