diff options
author | 2020-05-24 13:16:05 -0400 | |
---|---|---|
committer | 2020-05-24 13:16:05 -0400 | |
commit | 06f7a36d5fa444d15b3b66799b547cac57d9abc7 (patch) | |
tree | d1deac0aa6a9195c95b3b7e5bd8ebafa8041d685 | |
parent | 72a0869cabbf22d703d81f1e51db248e4f311d93 (diff) | |
download | textadept-06f7a36d5fa444d15b3b66799b547cac57d9abc7.tar.gz textadept-06f7a36d5fa444d15b3b66799b547cac57d9abc7.zip |
Always use capital drive letters when opening files in Windows.
Since Windows filenames are case-insensitive, mismatched drive letter case may
cause the same file to be open twice.
-rw-r--r-- | core/lfs_ext.lua | 4 | ||||
-rw-r--r-- | test/test.lua | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/core/lfs_ext.lua b/core/lfs_ext.lua index 59318da8..abf74dc0 100644 --- a/core/lfs_ext.lua +++ b/core/lfs_ext.lua @@ -124,7 +124,9 @@ end function lfs.abspath(filename, prefix) assert_type(filename, 'string', 1) assert_type(prefix, 'string/nil', 2) - if WIN32 then filename = filename:gsub('/', '\\') end + if WIN32 then + filename = filename:gsub('/', '\\'):gsub('^%l:[/\\]', string.upper) + end if not filename:find(not WIN32 and '^/' or '^%a:[/\\]') and not (WIN32 and filename:find('^\\\\')) then if not prefix then prefix = lfs.currentdir() end diff --git a/test/test.lua b/test/test.lua index 7fc53b75..1d920f6e 100644 --- a/test/test.lua +++ b/test/test.lua @@ -729,6 +729,7 @@ function test_lfs_ext_abs_path() assert_equal(lfs.abspath('.\\bar', 'C:\\foo'), 'C:\\foo\\bar') assert_equal(lfs.abspath('..\\bar', 'C:\\foo'), 'C:\\bar') assert_equal(lfs.abspath('C:\\bar', 'C:\\foo'), 'C:\\bar') + assert_equal(lfs.abspath('c:\\bar', 'c:\\foo'), 'C:\\bar') assert_equal(lfs.abspath('..\\../.\\./baz', 'C:\\foo\\bar'), 'C:\\baz') _G.WIN32 = win32 -- reset just in case |