Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorThijs <thijs@thijsschreijer.nl>2022-01-05 22:35:30 +0300
committerThijs Schreijer <thijs@thijsschreijer.nl>2022-01-05 22:52:22 +0300
commit585f0c5e98e19b2ca19bf8138b518c58198c0c09 (patch)
tree919a772aa6db25907d763a45827c462f7f22d71d /lua
parent98cb7f4a4f035595b9f794fed44b4f30f86b956e (diff)
fix(stringx) expandtabs failed on Lua 5.3+
Diffstat (limited to 'lua')
-rw-r--r--lua/pl/stringx.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/lua/pl/stringx.lua b/lua/pl/stringx.lua
index 8454f08..8ba6763 100644
--- a/lua/pl/stringx.lua
+++ b/lua/pl/stringx.lua
@@ -210,10 +210,14 @@ end
-- @usage stringx.expandtabs('\tone,two,three', 4) == ' one,two,three'
-- @usage stringx.expandtabs(' \tone,two,three', 4) == ' one,two,three'
function stringx.expandtabs(s,tabsize)
- assert_string(1,s)
- tabsize = tabsize or 8
- return (s:gsub("([^\t\r\n]*)\t", function(before_tab)
+ assert_string(1,s)
+ tabsize = tabsize or 8
+ return (s:gsub("([^\t\r\n]*)\t", function(before_tab)
+ if tabsize == 0 then
+ return before_tab
+ else
return before_tab .. (" "):rep(tabsize - #before_tab % tabsize)
+ end
end))
end