Skip to content

Commit c2dcced

Browse files
committed
fix: make devtools commands handle pub change
lsp-dart-pub-command has recently changed to produce a list instead, which breaks all the places it's expected in devtools.
1 parent a312fe8 commit c2dcced

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

lsp-dart-devtools.el

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
:type 'string)
3939

4040
(defconst lsp-dart-devtools--buffer-name "*LSP Dart - DevTools*")
41-
(defconst lsp-dart-devtools--pub-list-packages-buffer-name "*LSP Dart - Pub list packages*")
4241

4342
(defun lsp-dart-devtools-log (msg &rest args)
4443
"Custom logger for MSG and ARGS."
@@ -75,15 +74,9 @@ If URI is not found on buffer, schedule re-check."
7574

7675
(defun lsp-dart-devtools--activated-p ()
7776
"Return non-nil if devtools is activated otherwise nil."
78-
(lsp-dart-devtools--clean-buffer lsp-dart-devtools--pub-list-packages-buffer-name)
79-
(let* ((pub (lsp-dart-pub-command))
80-
(_proc (call-process pub
81-
nil
82-
lsp-dart-devtools--pub-list-packages-buffer-name
83-
nil
84-
"global" "list"))
85-
(content (lsp-dart-devtools--buffer-whole-string lsp-dart-devtools--pub-list-packages-buffer-name)))
86-
(string-match-p "devtools \\([0-9]\\.[0-9]\\.[0-9]\\)" content)))
77+
(let ((output (shell-command-to-string
78+
(mapconcat 'identity `(,@(lsp-dart-pub-command) "global" "list") " "))))
79+
(string-match-p "devtools \\([0-9]\\.[0-9]\\.[0-9]\\)" output)))
8780

8881
(defun lsp-dart-devtools--activate (callback)
8982
"Activate Dart Devtools via pub then call CALLBACK."
@@ -95,7 +88,7 @@ If URI is not found on buffer, schedule re-check."
9588
(funcall callback))
9689
(lambda (_) (lsp-dart-devtools-log "Could not activate DevTools. \
9790
Try to activate manually running 'pub global activate devtools'"))
98-
pub "global" "activate" "devtools")))
91+
(mapconcat 'identity `(,@pub "global" "activate" "devtools") " "))))
9992

10093
(defun lsp-dart-devtools--check-activated (callback)
10194
"Check if devtools is activated otherwise prompt for activate it.
@@ -120,13 +113,13 @@ If it is already activated or after activated successfully, call CALLBACK."
120113
(lambda ()
121114
(if-let ((uri (lsp-workspace-get-metadata "dart-debug-devtools-uri")))
122115
(funcall callback uri)
123-
(let* ((pub (lsp-dart-pub-command))
124-
(proc (start-process "Start DevTools"
125-
lsp-dart-devtools--buffer-name
126-
pub "global" "run" "devtools"
127-
"--machine"
128-
"--enable-notifications"
129-
"--try-ports" "10")))
116+
(let* ((pub (lsp-dart-pub-command))
117+
(proc (apply #'start-process "Start DevTools"
118+
lsp-dart-devtools--buffer-name
119+
`(,@pub "global" "run" "devtools"
120+
"--machine"
121+
"--enable-notifications"
122+
"--try-ports" "10"))))
130123
(add-hook 'dap-terminated-hook (-partial #'lsp-dart-devtools--kill-proc proc))
131124
(when lsp-dart-devtools--check-uri-timer
132125
(cancel-timer lsp-dart-devtools--check-uri-timer))

0 commit comments

Comments
 (0)