From e371c119ecc9044c8ca2d6b93215121eb714d6b1 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 8 Aug 2017 12:40:33 -0400 Subject: [PATCH] Don't keep region active when expanding from keymap * yasnippet.el (yas-expand-snippet): Only keep region active if we are going to field $0 and it has some text. --- yasnippet.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 94ccffb..aa9fe5e 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -3839,9 +3839,14 @@ considered when expanding the snippet." (when first-field (sit-for 0) ;; fix issue 125 (yas--letenv (yas--snippet-expand-env snippet) - (yas--move-to-field snippet first-field)))) + (yas--move-to-field snippet first-field)) + (when (and (eq (yas--field-number first-field) 0) + (> (length (yas--field-text-for-display + first-field)) + 0)) + ;; Keep region for ${0:exit text}. + (setq deactivate-mark nil)))) (yas--message 4 "snippet %d expanded." (yas--snippet-id snippet)) - (setq deactivate-mark nil) t)))) (defun yas--take-care-of-redo (_beg _end snippet)