From ed1ede43858fc865098724764f74be370b0eeeab Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 28 Apr 2018 16:04:11 -0400 Subject: [PATCH] lang/javascript: fix electric > not closing tags in rjsx-mode --- modules/lang/javascript/config.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/lang/javascript/config.el b/modules/lang/javascript/config.el index 9d52b951f..8efb27009 100644 --- a/modules/lang/javascript/config.el +++ b/modules/lang/javascript/config.el @@ -60,7 +60,16 @@ (set! :electric 'rjsx-mode :chars '(?\} ?\) ?. ?>)) (add-hook! 'rjsx-mode-hook ;; jshint doesn't know how to deal with jsx - (push 'javascript-jshint flycheck-disabled-checkers))) + (push 'javascript-jshint flycheck-disabled-checkers)) + + ;; `rjsx-electric-gt' relies on js2's parser to tell it when the cursor is in + ;; a self-closing tag, so that it can insert a matching ending tag at point. + ;; However, the parser doesn't run immediately, so a fast typist can outrun + ;; it, causing issues, so force it to parse. + (defun +javascript|reparse (n) + ;; if n != 0, then rjsx-maybe-reparse will be run elsewhere + (if (= n 0) (rjsx-maybe-reparse))) + (advice-add #'rjsx-electric-gt :before #'+javascript|reparse)) (def-package! coffee-mode