branch: elpa/typescript-mode
commit a0f2c3ebd4c7cde7f3c25f9cef12b679118d3351
Author: Louis-Dominique Dubeau <[email protected]>
Commit: Louis-Dominique Dubeau <[email protected]>
Reimplement template auto conversion as a post-self-insert-hook
This avoids bad interaction with delete-selection-mode and smartparens-mode.
---
typescript-mode.el | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/typescript-mode.el b/typescript-mode.el
index 1a0dcb5411..3ae8e16ae0 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -743,19 +743,16 @@ the string from a plain string to a template."
(defvar typescript-mode-map
(let ((keymap (make-sparse-keymap)))
- (dolist (key '("\"" "\'"))
- (define-key keymap key #'typescript-insert-and-autoconvert-to-template))
(define-key keymap (kbd "C-c '") #'typescript-convert-to-template)
keymap)
"Keymap for `typescript-mode'.")
-(defun typescript-insert-and-autoconvert-to-template (key)
- "Run the command bount to KEY, and autoconvert to template if necessary."
- (interactive (list (this-command-keys)))
- (call-interactively (lookup-key (current-global-map) key))
- (when typescript-autoconvert-to-template-flag
+(defun typescript--post-self-insert-function ()
+ (when (and (derived-mode-p 'typescript-mode)
+ typescript-autoconvert-to-template-flag
+ (or (eq last-command-event ?\')
+ (eq last-command-event ?\")))
(typescript-autoconvert-to-template)))
-(put 'typescript-insert-and-autoconvert-to-template 'delete-selection t)
;;; Syntax table and parsing
@@ -2843,6 +2840,9 @@ Key bindings:
(make-local-variable 'adaptive-fill-regexp)
(c-setup-paragraph-variables))
+ (add-hook 'post-self-insert-hook
+ #'typescript--post-self-insert-function)
+
(setq-local syntax-begin-function #'typescript--syntax-begin-function))
;; Set our custom predicate for flyspell prog mode