mirror of https://codeberg.org/cage/tinmop/
- fixed 'fs:relative-file-path->absolute' and 'complete:directory-complete'.
This commit is contained in:
parent
7abde425d8
commit
e5c7929166
|
@ -82,14 +82,9 @@ to the appropriate home directory."
|
|||
completed) and the common prefix of the completion string."
|
||||
(when (text-utils:string-not-empty-p string)
|
||||
(let* ((namestring (fs:relative-file-path->absolute (tilde-expand-string string)))
|
||||
(name-dir (if (fs:file-exists-p namestring)
|
||||
(fs:parent-dir-path namestring)
|
||||
namestring))
|
||||
(dir (namestring (pathname->directory-pathname namestring)))
|
||||
(name-dir namestring)
|
||||
(dir (namestring (pathname->directory-pathname name-dir)))
|
||||
(absolute-dir-path (fs:relative-file-path->absolute dir)))
|
||||
(unless (and (underlying-directory-p dir)
|
||||
(not (wild-pathname-p dir)))
|
||||
(return-from directory-complete (values nil 0)))
|
||||
(let* ((all (fs:collect-children absolute-dir-path))
|
||||
(candidates (sort (remove-if-not (lambda (a)
|
||||
(text-utils:string-starts-with-p name-dir
|
||||
|
|
|
@ -308,13 +308,18 @@ symbolic link."
|
|||
(resolved-path :pointer))
|
||||
|
||||
(defun relative-file-path->absolute (path)
|
||||
(let ((absolute-path (cffi:with-foreign-string (ptr-path path)
|
||||
(let ((resolved ""))
|
||||
"NB: returns `PATH` if the FFI call to `realpath` returns NULL."
|
||||
(let ((absolute-path (let ((resolved ""))
|
||||
(cffi:with-foreign-string (ptr-path path)
|
||||
(cffi:with-foreign-string (ptr-resolved resolved)
|
||||
(ffi-realpath ptr-path ptr-resolved))))))
|
||||
(if (dirp absolute-path)
|
||||
(cat-parent-dir absolute-path *directory-sep*)
|
||||
absolute-path)))
|
||||
(cond
|
||||
((null absolute-path)
|
||||
path)
|
||||
((dirp absolute-path)
|
||||
(cat-parent-dir absolute-path *directory-sep*))
|
||||
(t
|
||||
absolute-path))))
|
||||
|
||||
(defun regular-file-p (path)
|
||||
(nix:s-isreg (nix:stat-mode (nix:stat path))))
|
||||
|
|
Loading…
Reference in New Issue