@@ -423,6 +423,11 @@ interpreted as `in'."
423423 ; ; buffer modified anymore. This is also an indicator for when undo's
424424 ; ; can be made in the buffer.
425425 (set-buffer-modified-p nil )
426+ ; ; FIX: Figure out why Emacs hangs if we parse right now.
427+ (when tree-sitter-mode
428+ (run-with-idle-timer 0 nil
429+ (lambda ()
430+ (tree-sitter-resume))))
426431 (setq buffer-undo-list '((t . 0 ))))
427432 ((eq type 'out )
428433 ; ; Output is normally inserted by first going to the end of the output
@@ -730,6 +735,14 @@ POS defaults to `point'."
730735REQ is the `jupyter-request' to associate with the current cell.
731736Place `point' at `point-max' ."
732737 (goto-char (point-max ))
738+ (when (and (bound-and-true-p tree-sitter-mode)
739+ (functionp 'tree-sitter-pause ))
740+ (tree-sitter-pause))
741+ (when (and (bound-and-true-p tree-sitter-hl-mode)
742+ (functionp 'tree-sitter-hl-dry-up-region ))
743+ (tree-sitter-hl-dry-up-region
744+ (jupyter-repl-cell-code-beginning-position)
745+ (jupyter-repl-cell-code-end-position)))
733746 (let ((beg (jupyter-repl-cell-beginning-position))
734747 (count (jupyter-repl-cell-count)))
735748 (jupyter-repl-newline)
@@ -1731,6 +1744,16 @@ Return the buffer switched to."
17311744 (add-hook 'kill-buffer-hook #'jupyter-repl--deactivate-interaction-buffers nil t )
17321745 (add-hook 'after-change-functions 'jupyter-repl-do-after-change nil t )
17331746 (add-hook 'pre-redisplay-functions 'jupyter-repl-preserve-window-margins nil t )
1747+ (setq-local tree-sitter-get-parse-region-function
1748+ (lambda ()
1749+ ; ; TODO: Return an empty region when we don't have an input
1750+ ; ; cell ready.
1751+ (save-excursion
1752+ (save-restriction
1753+ (widen )
1754+ (goto-char (point-max ))
1755+ (cons (jupyter-repl-cell-code-beginning-position)
1756+ (jupyter-repl-cell-code-end-position))))))
17341757 ; ; Initialize the REPL
17351758 (jupyter-repl-initialize-fontification)
17361759 (jupyter-repl-isearch-setup)
0 commit comments