Skip to content

Commit a312fe8

Browse files
committed
Fix lsp-dart-run when default-directory is not the project root
Fixes #173
1 parent 7868b87 commit a312fe8

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
* Fix `lsp-dart-run` when default-directory is not the project root. #173
6+
57
## 1.22.2
68

79
* Fix `(wront-type-argument stringp ("daemon"))` on last version. #171

lsp-dart-test-support.el

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ NOTIFICATION is the event notification.")
180180
(defun lsp-dart-test--run-process (command &optional args)
181181
"Spawn COMMAND with ARGS on a separated buffer."
182182
(lsp-dart-test--clean-process-buffer)
183-
(let ((process-buffer (get-buffer-create lsp-dart-test--process-buffer-name))
184-
(project-rt (lsp-dart-get-project-root)))
183+
(let ((process-buffer (get-buffer-create lsp-dart-test--process-buffer-name)))
185184
(with-current-buffer process-buffer
186-
(setq-local default-directory (or project-rt default-directory))
185+
(setq-local default-directory (or (lsp-dart-get-project-root) default-directory))
187186
(unless (derived-mode-p 'lsp-dart-test-process-mode)
188187
(lsp-dart-test-process-mode))
189188
(apply #'make-comint-in-buffer lsp-dart-test--process-buffer-name process-buffer (car command) nil (append (cdr command) args)))))

lsp-dart-utils.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ FLUTTER_ROOT environment variable."
174174

175175
(defun lsp-dart-get-project-root ()
176176
"Return the dart or flutter project root."
177-
(-some-> default-directory
178-
(locate-dominating-file "pubspec.yaml")
179-
file-truename))
177+
(or (lsp-workspace-root)
178+
(-some-> default-directory
179+
(locate-dominating-file "pubspec.yaml")
180+
file-truename)))
180181

181182
(defun lsp-dart-get-project-entrypoint ()
182183
"Return the dart or flutter project entrypoint."

0 commit comments

Comments
 (0)