Skip to content

Commit

Permalink
Use root directory before opening project file
Browse files Browse the repository at this point in the history
  • Loading branch information
jfaz1 committed Mar 1, 2025
1 parent 7e58599 commit a2dd7af
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/commands/project.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -176,30 +176,30 @@
(declare (ignorable arg))
(let* ((cwd (buffer-directory))
(project-root (find-root cwd))
(root (or project-root cwd))
(filename (if (and *respect-gitignore* (git-repository-p root))
;; In a git repo and respecting gitignore, use git ls-files
(uiop:with-current-directory (root)
(let ((files (list-project-files-git root)))
(if files
(prompt-for-string
"Find file: "
:completion-function (lambda (x)
(completion-strings x files))
:test-function (lambda (name)
(member name files :test #'string=)))
;; Fallback if ls-files fails
(prompt-for-files-recursively))))
;; Use regular prompt
(uiop:with-current-directory (root)
(prompt-for-files-recursively))))
buffer)
(when filename
(setf buffer (execute-find-file *find-file-executor*
(get-file-mode filename)
filename))
(when buffer
(switch-to-buffer buffer t nil)))))
(root (or project-root cwd)))
(uiop:with-current-directory (root)
(let ((filename
(if (and *respect-gitignore* (git-repository-p root))
;; In a git repo and respecting gitignore, use git ls-files
(let ((files (list-project-files-git root)))
(if files
(prompt-for-string
"Find file: "
:completion-function (lambda (x)
(completion-strings x files))
:test-function (lambda (name)
(member name files :test #'string=)))
;; Fallback if ls-files fails
(prompt-for-files-recursively)))
;; Use regular prompt
(prompt-for-files-recursively))))
(when filename
(let* ((absolute-filename (merge-pathnames filename root))
(buffer (execute-find-file *find-file-executor*
(get-file-mode absolute-filename)
absolute-filename)))
(when buffer
(switch-to-buffer buffer t nil))))))))

(define-command project-root () ()
"Display this buffer's project directory."
Expand Down

0 comments on commit a2dd7af

Please sign in to comment.