mirror of
https://github.com/neovim/neovim.git
synced 2025-09-09 04:48:18 +00:00
@@ -2089,8 +2089,15 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf, int len, int
|
|||||||
// expand it if forced or not an absolute path
|
// expand it if forced or not an absolute path
|
||||||
if (force || !path_is_absolute_path(fname)) {
|
if (force || !path_is_absolute_path(fname)) {
|
||||||
if ((p = vim_strrchr(fname, '/')) != NULL) {
|
if ((p = vim_strrchr(fname, '/')) != NULL) {
|
||||||
STRNCPY(relative_directory, fname, p-fname);
|
// relative to root
|
||||||
relative_directory[p-fname] = NUL;
|
if (p == fname) {
|
||||||
|
// only one path component
|
||||||
|
relative_directory[0] = '/';
|
||||||
|
relative_directory[1] = NUL;
|
||||||
|
} else {
|
||||||
|
STRNCPY(relative_directory, fname, p-fname);
|
||||||
|
relative_directory[p-fname] = NUL;
|
||||||
|
}
|
||||||
end_of_path = (char *) (p + 1);
|
end_of_path = (char *) (p + 1);
|
||||||
} else {
|
} else {
|
||||||
relative_directory[0] = NUL;
|
relative_directory[0] = NUL;
|
||||||
|
@@ -416,6 +416,14 @@ describe('more path function', function()
|
|||||||
eq('unit-test-directory/test.file', (ffi.string(filename)))
|
eq('unit-test-directory/test.file', (ffi.string(filename)))
|
||||||
eq(OK, result)
|
eq(OK, result)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('works with directories that have one path component', function()
|
||||||
|
local force_expansion = 1
|
||||||
|
local filename = to_cstr('/tmp')
|
||||||
|
local result = path.vim_FullName(filename, buffer, len, force_expansion)
|
||||||
|
eq('/tmp', ffi.string(buffer))
|
||||||
|
eq(OK, result)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('path_fix_case', function()
|
describe('path_fix_case', function()
|
||||||
|
Reference in New Issue
Block a user