Skip to content

Commit 26d5565

Browse files
committed
Prevent project creation from crashing in dired
Dired does not set `buffer-file-name`. We have to fallback to `default-directory` in this case.
1 parent acba112 commit 26d5565

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ede-php-autoload-composer.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ information into AUTOLOADS."
190190
"Auto-detect composer project root.
191191
192192
Return the parent directory of the current buffer file that contains a composer.json file."
193-
(let ((dominating-file (locate-dominating-file (buffer-file-name) ede-php-autoload-composer-file)))
193+
(let ((dominating-file (locate-dominating-file (or (buffer-file-name) default-directory) ede-php-autoload-composer-file)))
194194
(when dominating-file
195195
(file-name-directory dominating-file))))
196196

test/ede-php-autoload-test.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
(should (string= (car (oref (ede-current-project) :system-include-path))
4343
"/usr/share/php"))))
4444

45+
(ert-deftest ede-php-autoload-creates-project-in-dired ()
46+
"The EDE php autoload project instanciates properly in a dired buffer."
47+
(with-current-project-file "." "without-composer"
48+
(should (ede-php-autoload-project-p (ede-current-project)))))
49+
4550
;; Class loading tests
4651
(define-class-definition-test ede-php-autoload-find-psr0 ()
4752
"The definition for a PSR-4 class should be found."

0 commit comments

Comments
 (0)