diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-09-18 17:14:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-18 17:14:25 +0200 |
commit | 6cad86fffdb91d3997a707ff6adb0b5991587b3e (patch) | |
tree | b929329658316d6a8a7aead01f0b701c0e278fca /src/nvim/api/vim.c | |
parent | 8ef2b56cac895c151345cf0ff0a97456c0a7fdd2 (diff) | |
parent | a860f7880fd5d5cef5299ff8d450ac037bee2300 (diff) | |
download | rneovim-6cad86fffdb91d3997a707ff6adb0b5991587b3e.tar.gz rneovim-6cad86fffdb91d3997a707ff6adb0b5991587b3e.tar.bz2 rneovim-6cad86fffdb91d3997a707ff6adb0b5991587b3e.zip |
Merge pull request #15632 from bfredl/rtptest
runtime: always use DIP_START and remove duplication of start packages in &rtp
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 51 |
1 files changed, 3 insertions, 48 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index f65d5cc185..e764c45f0e 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -750,47 +750,10 @@ Integer nvim_strwidth(String text, Error *err) /// Gets the paths contained in 'runtimepath'. /// /// @return List of paths -ArrayOf(String) nvim_list_runtime_paths(void) +ArrayOf(String) nvim_list_runtime_paths(Error *err) FUNC_API_SINCE(1) { - // TODO(bfredl): this should just work: - // return nvim_get_runtime_file(NULL_STRING, true); - - Array rv = ARRAY_DICT_INIT; - - char_u *rtp = p_rtp; - - if (*rtp == NUL) { - // No paths - return rv; - } - - // Count the number of paths in rtp - while (*rtp != NUL) { - if (*rtp == ',') { - rv.size++; - } - rtp++; - } - rv.size++; - - // Allocate memory for the copies - rv.items = xmalloc(sizeof(*rv.items) * rv.size); - // Reset the position - rtp = p_rtp; - // Start copying - for (size_t i = 0; i < rv.size; i++) { - rv.items[i].type = kObjectTypeString; - rv.items[i].data.string.data = xmalloc(MAXPATHL); - // Copy the path from 'runtimepath' to rv.items[i] - size_t length = copy_option_part(&rtp, - (char_u *)rv.items[i].data.string.data, - MAXPATHL, - ","); - rv.items[i].data.string.size = length; - } - - return rv; + return nvim_get_runtime_file(NULL_STRING, true, err); } /// Find files in runtime directories @@ -802,10 +765,6 @@ ArrayOf(String) nvim_list_runtime_paths(void) /// /// It is not an error to not find any files. An empty array is returned then. /// -/// To find a directory, `name` must end with a forward slash, like -/// "rplugin/python/". Without the slash it would instead look for an ordinary -/// file called "rplugin/python". -/// /// @param name pattern of files to search for /// @param all whether to return all matches or only the first /// @return list of absolute paths to the found files @@ -815,11 +774,7 @@ ArrayOf(String) nvim_get_runtime_file(String name, Boolean all, Error *err) { Array rv = ARRAY_DICT_INIT; - int flags = DIP_START | (all ? DIP_ALL : 0); - - if (name.size == 0 || name.data[name.size-1] == '/') { - flags |= DIP_DIR; - } + int flags = DIP_DIRFILE | (all ? DIP_ALL : 0); do_in_runtimepath((char_u *)(name.size ? name.data : ""), flags, find_runtime_cb, &rv); |