Skip to content

Commit

Permalink
Fix #37 Wait for js2 parsing to be done
Browse files Browse the repository at this point in the history
Before getting the js2 AST node to evaluate, make sure parsing is finished.
  • Loading branch information
NicolasPetton committed Apr 25, 2017
1 parent 72e8e44 commit bab0a1d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions indium-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ Interactively, with a prefix argument ARG, print output into
current buffer."
(interactive "P")
(indium-interaction--ensure-connection)
(indium-eval (js2-node-string (indium-interaction-node-before-point))
(lambda (value _error)
(let ((description (indium-render-value-to-string value)))
(if arg
(save-excursion
(insert description))
(indium-message "%s" description))))))
(js2-mode-wait-for-parse
(lambda ()
(indium-eval (js2-node-string (indium-interaction-node-before-point))
(lambda (value _error)
(let ((description (indium-render-value-to-string value)))
(if arg
(save-excursion
(insert description))
(indium-message "%s" description))))))))

(defun indium-reload ()
"Reload the page."
Expand All @@ -71,9 +73,11 @@ current buffer."
"Evaluate and inspect the node before point."
(interactive)
(indium-interaction--ensure-connection)
(indium-eval (js2-node-string (indium-interaction-node-before-point))
(lambda (result _error)
(indium-inspector-inspect result))))
(js2-mode-wait-for-parse
(lambda ()
(indium-eval (js2-node-string (indium-interaction-node-before-point))
(lambda (result _error)
(indium-inspector-inspect result))))))

(defun indium-switch-to-repl-buffer ()
"Switch to the repl buffer if any."
Expand Down

0 comments on commit bab0a1d

Please sign in to comment.