aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+orbitalquark@users.noreply.github.com>2020-11-03 11:24:27 -0500
committermitchell <70453897+orbitalquark@users.noreply.github.com>2020-11-03 11:24:27 -0500
commit87a11d65ee576d965bcf432e878f191512e46bdd (patch)
tree193ffc07d4bf4e0423e9e45ef8110639568ef9eb
parent85b8810660ffa37eb2d3edf85a4dbf12ba5f1ca3 (diff)
downloadtextadept-87a11d65ee576d965bcf432e878f191512e46bdd.tar.gz
textadept-87a11d65ee576d965bcf432e878f191512e46bdd.zip
Fixed `lfs.walk()` bug with root directory.
Prevent dir to walk from becoming an empty string.
-rw-r--r--core/lfs_ext.lua2
-rw-r--r--test/test.lua5
2 files changed, 6 insertions, 1 deletions
diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua
index d55dbf0b..842c1737 100644
--- a/core/lfs_ext.lua
+++ b/core/lfs_ext.lua
@@ -85,7 +85,7 @@ end
-- @see filter
-- @name walk
function lfs.walk(dir, filter, n, include_dirs)
- dir = assert_type(dir, 'string', 1):match('^(.-)[/\\]?$')
+ dir = assert_type(dir, 'string', 1):match('^(..-)[/\\]?$')
if not assert_type(filter, 'string/table/nil', 2) then
filter = lfs.default_filter
end
diff --git a/test/test.lua b/test/test.lua
index 53a7cb24..8a768731 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -759,6 +759,11 @@ function test_lfs_ext_walk_symlinks()
os.execute('rm -r ' .. dir)
end
+function test_lfs_ext_walk_root()
+ local filename = lfs.walk('/', nil, 0, true)()
+ assert(not filename:find('lfs_ext.lua:'), 'coroutine error')
+end
+
function test_lfs_ext_abs_path()
assert_equal(lfs.abspath('bar', '/foo'), '/foo/bar')
assert_equal(lfs.abspath('./bar', '/foo'), '/foo/bar')