File tree 2 files changed +3
-1
lines changed
2 files changed +3
-1
lines changed Original file line number Diff line number Diff line change 97
97
--- Removes the trailing separator (if any) from a directory, for both unix and windows
98
98
--- This is needed in some places to avoid duplicate separators that complicate
99
99
--- the path and make equality checks fail (e.g. session control alternate)
100
+ -- Will return '/' if that's the only part of the path
100
101
--- @param dir string The directory path to make sure doesn ' t have a trailing separator
101
102
--- @return string Dir guaranteed to not have a trailing separator
102
103
function Lib .remove_trailing_separator (dir )
@@ -105,7 +106,7 @@ function Lib.remove_trailing_separator(dir)
105
106
dir = dir :gsub (" \\ $" , " " )
106
107
end
107
108
108
- return (dir :gsub (" /$" , " " ))
109
+ return (dir :gsub (" (.) /$" , " %1 " ))
109
110
end
110
111
111
112
--- Legacy decoding function for windows. Replaces ++ with : and - with \
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ describe("Lib / Helper functions", function()
24
24
it (" remove_trailing_separator works" , function ()
25
25
assert .equals (" /tmp/blah" , Lib .remove_trailing_separator " /tmp/blah/" )
26
26
assert .equals (" /tmp/blah" , Lib .remove_trailing_separator " /tmp/blah" )
27
+ assert .equals (" /" , Lib .remove_trailing_separator " /" )
27
28
28
29
if vim .fn .has " win32" == 1 then
29
30
assert .equals (" c:\\ temp\\ blah" , Lib .remove_trailing_separator " c:\\ temp\\ blah\\ " )
You can’t perform that action at this time.
0 commit comments