8000 `treefmt --stdin` doesn't work if the underlying formatter cares about the real filename · Issue #573 · numtide/treefmt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
treefmt --stdin doesn't work if the underlying formatter cares about the real filename #573
Open
@MagicRB

Description

@MagicRB

Describe the bug

So the default behavior of treefmt, is to to not pass the file path to the downstream formatter if formatting via stdin. But that subtly breaks fourmolu, it fails to pull in the active Haskell extensions. So fourmolu -i -c fat-hs/src/MyLib.hs < fat-hs/src/MyLib.hs works, but fourmolu -i -c < fat-hs/src/MyLib.hs doesn't. I don't quite see from the code, where does the path get omitted,

func (f *Formatter) Apply(ctx context.Context, files []*walk.File) error {
I was looking there, and I think it comes from files, which is empty in the case of stdin formatting I guess.

To Reproduce

  1. clone my thesis repo https://git.redalder.org/magic_rb/bsc-thesis
  2. try to format fat-hs/src/MyLib.hs using treefmt, so: treefmt --stdin fat-hs/src/MyLib.hs < fat-hs/src/MyLib.hs

Expected behavior

Formatting is consistent between stdin mode and direct mode

System information

NixOS 25.05, exact versions of everything are pinned in https://git.redalder.org/magic_rb/bsc-thesis
Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0