Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect indentation when folding a record update expression #536

Closed
SteveGilham opened this issue Oct 22, 2019 · 5 comments
Closed

Incorrect indentation when folding a record update expression #536

SteveGilham opened this issue Oct 22, 2019 · 5 comments

Comments

@SteveGilham
Copy link

Description

Formatted code gives

 (8,16)-(9,22):  Warning FS0058: Possible incorrect indentation: this token is offside of context started at position (7:47). Try indenting this token further or using standard formatting conventions.

Repro code

https://jindraivanek.gitlab.io/fantomas-ui/#?code=ATDawIgOgegQwDYBcDGB7AbgUwE5R1ujgCa5RFZQDOCAdhANySyKqZkXV2PMwDKcALYAHBFgCMAFn5DREyV3rAAugFgAUCAA+APmB8sARygBLJLmAAKAGYBXWsCrAAtHqoaQnr959fdwABE0JAA5LCQoACNbEwRiD19EpJt7YGEXHQSk7K8AbzSoAHUzAAsAYTRBQTQHYmDacIB5YSQTGqcAd1LgCtprEwBzWxw4VprgAF5A4LCIgCEYuN7+oZGx2igArGiB4ABfLJyc-y6kEoBZPgXY4gAFOBHBKgBKZ6A&config=N4IgkgdgJgphAuBlADgQwMYwHIFcC2IAXAEwA0IACqgOYwDqAllPABZECcADAL5A

@theimowski
Copy link
Member

Another instance of same issue:

Issue created from fantomas-ui

The sample here is a bit extreme as I used 20 for page width, but I was able to reproduce same behaviour with more representative production code.
The result of formatting issues an indentation warning, as 3 starts in same column as with keyword
There exists a valid syntax for those settings, where with follows with a line break (see Expected section)

Code

type A =
  { Number : int }

let a = { Number = 2 }

let b = 
  { a with Number = 3 }

Result

type A =
  { Number: int }

let a =
  { Number = 2 }

let b =
  { a with Number =
      3 }

Expected

type A =
  { Number: int }

let a =
  { Number = 2 }

let b =
  { a with 
      Number = 3 }

Options

Fantomas 3.0.0

Name Value
IndentOnTryWith false
IndentSpaceNum 2
KeepNewlineAfter false
PageWidth 20
ReorderOpenDeclaration false
SemicolonAtEndOfLine false
SpaceAfterComma true
SpaceAfterSemicolon true
SpaceAroundDelimiter true
SpaceBeforeArgument true
SpaceBeforeColon false
StrictMode false

@drhumlen
Copy link

drhumlen commented Apr 9, 2020

I get this warning quite often too. It would be really nice to have this patched.

Warnings are usually something that should be taken seriously (like non-exhaustive pattern matching). It would be nice to have warnings be a blocker on PRs / give error on CI builds.

@drhumlen
Copy link

drhumlen commented Apr 9, 2020

Imo the suggested formatting looks much better too 😄

@drhumlen
Copy link

#744

@nojaf
Copy link
Contributor

nojaf commented May 8, 2020

Not a problem anymore.

@nojaf nojaf closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants