From c09777b36bcdea2bda904f1fa153f0efae2f4df8 Mon Sep 17 00:00:00 2001 From: Quoc Huy Vu Date: Thu, 18 Nov 2021 02:51:45 +0100 Subject: [PATCH] fix(evil): handle edge cases of embrace If the surround key is `\(`, the text should be surrounded as `\( text \)`. The same for `\[` and `\{`. --- modules/editor/evil/autoload/embrace.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/editor/evil/autoload/embrace.el b/modules/editor/evil/autoload/embrace.el index 37a825e78..6090112ea 100644 --- a/modules/editor/evil/autoload/embrace.el +++ b/modules/editor/evil/autoload/embrace.el @@ -17,10 +17,11 @@ (let ((char (read-char "\\"))) (if (eq char 27) (cons "" "") - (let ((pair (+evil--embrace-get-pair (string char))) - (text (if (sp-point-in-string) "\\\\%s" "\\%s"))) - (cons (format text (car pair)) - (format text (cdr pair))))))) + (let* ((pair (+evil--embrace-get-pair (string char))) + (escape (if (sp-point-in-string) "\\\\" "\\")) + (escape (format "\\1%s" (regexp-quote escape)))) + (cons (replace-regexp-in-string "^\\( *\\)" escape (car pair)) + (replace-regexp-in-string "^\\( *\\)" escape (cdr pair))))))) ;;;###autoload (defun +evil--embrace-latex ()