Skip to content

Need to track file locations through formatting #433

@cdsmith

Description

@cdsmith

I'm attempting to integrate ormolu into an interactive editor. When formatting runs, I have to throw away all location information, and this is a jarring experience. Since you have original source locations in the parsed AST, might it be possible to pass in a list of SrcLoc values, and get back a list of the corresponding locations after formatting? This would be awesome.

(I can, of course, try to recover this information after formatting with some kind of a fuzzy diff, but this will by necessity be guessing information after it's been thrown away. Ormolu itself has the information it needs to give a precise answer; that is, it already KNOWS which source location this bit of syntax was at in the original file, at the time that it's rendering the formatted version.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions