vim-patch:8.2.4838: checking for absolute path is not trivial (#29990)

Problem:    Checking for absolute path is not trivial.
Solution:   Add isabsolutepath(). (closes vim/vim#10303)

dca1d40cd0

vim-patch:8a3b805c6c9c

Co-authored-by: LemonBoy <thatlemon@gmail.com>
This commit is contained in:
zeertzjq
2024-08-06 21:19:12 +08:00
committed by GitHub
parent 28fbba2092
commit 37952bf7b4
6 changed files with 82 additions and 0 deletions

View File

@@ -4659,6 +4659,24 @@ function vim.fn.interrupt() end
--- @return any
function vim.fn.invert(expr) end
--- The result is a Number, which is |TRUE| when {path} is an
--- absolute path.
--- On Unix, a path is considered absolute when it starts with '/'.
--- On MS-Windows, it is considered absolute when it starts with an
--- optional drive prefix and is followed by a '\' or '/'. UNC paths
--- are always absolute.
--- Example: >vim
--- echo isabsolutepath('/usr/share/') " 1
--- echo isabsolutepath('./foobar') " 0
--- echo isabsolutepath('C:\Windows') " 1
--- echo isabsolutepath('foobar') " 0
--- echo isabsolutepath('\\remote\file') " 1
--- <
---
--- @param path any
--- @return 0|1
function vim.fn.isabsolutepath(path) end
--- The result is a Number, which is |TRUE| when a directory
--- with the name {directory} exists. If {directory} doesn't
--- exist, or isn't a directory, the result is |FALSE|. {directory}