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

fix padWithLinebreaks by switching to upstream FAIAP #1194

Merged
merged 4 commits into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions WeakAurasOptions/ForAllIndentsAndPurposes.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- For All Indents And Purposes
local revision = 21
local revision = 22
-- Maintainer: kristofer.karlsson@gmail.com

-- For All Indents And Purposes -
Expand Down Expand Up @@ -976,14 +976,26 @@ if not IndentationLib.revision or revision > IndentationLib.revision then
local linebreak = stringbyte("\n")
function lib.padWithLinebreaks(code)
local len = stringlen(code)
if stringbyte(code, len) == linebreak then
if stringbyte(code, len - 1) == linebreak then
return code, false
local linebreakcount = 0
while len > 0 and linebreakcount < 2 do
local b = stringbyte(code, len)
if b == linebreak then
linebreakcount = linebreakcount + 1
elseif whitespaceCharacters[b] then
-- Ignore whitespace characters
else
break
end
return code .. "\n", true
len = len - 1
end
return code .. "\n\n", true

if linebreakcount == 0 then
return code .. "\n\n", true
elseif linebreakcount == 1 then
return code .. "\n", true
else
return code, false
end
end

-- Data tables
Expand Down