Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua-fmt requires multiple runs to format a Lua file due to comments #25

Open
henriquegemignani opened this issue Aug 27, 2018 · 0 comments
Labels

Comments

@henriquegemignani
Copy link

henriquegemignani commented Aug 27, 2018

When formatting the following code sample:

local MyModule = require("MyModule")

--[[
    Small string
]]--



-- ==================
-- = Helper Methods =
-- ==================

local function someFunction()
    return 5
end

We get the following result:

local MyModule = require("MyModule")
 --

--[[
    Small string
]] -- ==================
-- = Helper Methods =
-- ==================

local function someFunction()
    return 5
end

If we run lua-fmt in that snippet, we get this second output:

local MyModule = require("MyModule") -- ==================
--

--[[
    Small string
]] -- = Helper Methods =
-- ==================

local function someFunction()
    return 5
end

A third use gives yet another output:

local MyModule = require("MyModule") -- ================== -- = Helper Methods =
--

--[[
    Small string
]] -- ==================

local function someFunction()
    return 5
end

A fourth use is thankfully final:

local MyModule = require("MyModule") -- ================== -- = Helper Methods = -- ==================
--

--[[
    Small string
]] local function someFunction()
    return 5
end

This simple edit in the original resolves all issues:

local MyModule = require("MyModule")

--[[
    Small string
]]



-- ==================
-- = Helper Methods =
-- ==================

local function someFunction()
    return 5
end

(removed the -- after the "Small string" comment)

Running lua-fmt via vscode-lua 0.12.4

@henriquegemignani henriquegemignani changed the title lua-fmt requires multiple runs to format a Lua file lua-fmt requires multiple runs to format a Lua file due to comments Aug 27, 2018
@trixnz trixnz added the bug label Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants