Active patterns with defined with otherwise invalid name is incorrectly re-formatted
Issue created from fantomas-online
Code
let (|``Custom Prefix``|_|) (p: string) (s: string) =
if s.StartsWith(p) then
Some(s.Substring(p.Length))
else
None
Result
let (|Custom Prefix|_|) (p: string) (s: string) =
if s.StartsWith(p) then
Some(s.Substring(p.Length))
else
None
Problem description
Please describe here the Fantomas problem you encountered. Check out our Contribution Guidelines.
Extra information
- [x] The formatted result breaks my code.
- [x] The formatted result gives compiler warnings.
- [x] I or my company would be willing to help fix this.
- [ ] I would like a release if this problem is solved.
Options
Fantomas main branch at 1/1/1990
Default Fantomas configuration
Did you know that you can ignore files when formatting by using a .fantomasignore file? PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.
You should snatch the original ident text from source code in https://github.com/fsprojects/fantomas/blob/06d86ad91974467f0e82f5f0ca7d3c58eef7e859/src/Fantomas.Core/ASTTransformer.fs#L42
using creationAide.TextFromSource fallback range.
Actually, we should reuse the logic of https://github.com/fsprojects/fantomas/blob/06d86ad91974467f0e82f5f0ca7d3c58eef7e859/src/Fantomas.Core/ASTTransformer.fs#L25-L42 instead (ident.idText.Length + 4 = width) perhaps.