Skip to content

Preserve spaces around interpolated expressions in format strings, in user-defined functions #3334

@muzimuzhi

Description

@muzimuzhi

When formatting a justfile containing user-defined functions which uses format strings in function bodies and arguments, the spaces around interpolated expressions in format strings were removed.

But in (almost?) all other places, such spaces are preserved.

set unstable

info(msg) := f"{{ BOLD + BLUE + msg + NORMAL }}"

echo:
    echo {{ info(f"{{ justfile() }}") }}
    echo {{ justfile() }}
    echo f"{{ justfile() }}"

just --fmt --check then gives

 set unstable

-info(msg) := f"{{ BOLD + BLUE + msg + NORMAL }}"
+info(msg) := f"{{BOLD + BLUE + msg + NORMAL}}"

 echo:
-    echo {{ info(f"{{ justfile() }}") }}
+    echo {{ info(f"{{justfile()}}") }}
     echo {{ justfile() }}
     echo f"{{ justfile() }}"
error: Formatted justfile differs from original.
$ just --version
just 1.50.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions