Skip to content

meson fmt -e inconsistent formatting when using either stdin or a different working directory #14423

Open
0 of 2 issues completed
@tmuehlbacher

Description

@tmuehlbacher

Describe the bug

Meson doesn't know the file name when formatting according to editorconfig and
hence cannot correctly deduce the correct config when using stdin.

To Reproduce try meson fmt -e on https://github.com/fwupd/fwupd/tree/2.0.7

There is a difference when using meson fmt with editorconfig enabled between
regular file path and reading from stdin. This seems likely because the stdin
- matches only against [*].

$ editorconfig $(realpath meson.build)
charset=utf-8
end_of_line=lf
indent_size=2
indent_style=space
insert_final_newline=true
max_line_length=100
tab_width=8
trim_trailing_whitespace=true

$ diff -u <(meson fmt -e meson.build) <(meson fmt -e - <meson.build)
...

Using stdin is preferable for use with some editor formatting plugins, at
least for Emacs format-all support. Since this allows for formatting the editor
buffer contents without first writing them to a file.

A solution could possibly require adding a separate argument that allows
supplying a file name just for editorconfig eval but without touching that file
path.

There is also a difference when it comes to the working directory.

$ editorconfig $(realpath data/meson.build)
charset=utf-8
end_of_line=lf
indent_size=2
indent_style=space
insert_final_newline=true
max_line_length=100
tab_width=8
trim_trailing_whitespace=true

$ diff -u <(meson fmt -e data/meson.build) <(cd data; meson fmt -e meson.build)

Here it seems that an editorconfig file in a parent dir is not evaluated.

Expected behavior is that meson fmt has consistent output with the
--editor-config option regardless of using stdin and regardless of current
working directory.

system parameters

  • what operating system: NixOS unstable (25.05.20250326.f55926c)
  • what Python version are you using: 3.12.9
  • what meson --version: 1.7.0

Sub-issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions