Skip to content

luafmt emits trailing whitespace on blank lines inside tab-indented blocks #1090

@ealap

Description

@ealap

When formatting Lua files that contain blank lines inside indented blocks (e.g. between statements in a function body or between table fields), luafmt produces lines that contain leading whitespace matching the current indentation level rather than being truly blank.

   local function foo()
       local a = 1
------- <- luafmt adds indent here 
       local b = 2
   end

Expected behavior:

I expect a blank line to contain no characters, just a newline.

If this was intentional, please add an option to configure it. Many editors and git hooks can be configured to strip trailing whitespace on save. When that setting is enabled, the file is modified every time it is saved after being formatted, creating a persistent diff where luafmt and the editor continuously undo each other's changes.

My workaround for now is to set max_blank_lines = 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions