From aa68ee74fd85723f40f7a5202009ebab09184215 Mon Sep 17 00:00:00 2001 From: Dave Mayo Date: Wed, 26 Nov 2014 00:26:46 -0500 Subject: Fixes #54 - Uses looking-back to check if there is a tag immediately preceding in cases where ">" is before-char --- src/mode-def.el | 7 +++---- src/test.el | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mode-def.el b/src/mode-def.el index b3c7541..418be9c 100644 --- a/src/mode-def.el +++ b/src/mode-def.el @@ -19,7 +19,6 @@ "Find the left bound of an emmet expr" (save-excursion (save-match-data (let ((char (char-before)) - (last-gt (point)) (in-style-attr (looking-back "style=[\"'][^\"']*"))) (while char (cond ((and in-style-attr (member char '(?\" ?\'))) @@ -28,9 +27,9 @@ (with-syntax-table (standard-syntax-table) (backward-sexp) (setq char (char-before)))) ((eq char ?\>) - (setq last-gt (point)) (backward-char) (setq char (char-before))) - ((eq char ?\<) - (goto-char last-gt) (setq char nil)) + (if (looking-back "<[^>]+>" (line-beginning-position)) + (setq char nil) + (progn (backward-char) (setq char (char-before))))) ((not (string-match-p "[[:space:]\n;]" (string char))) (backward-char) (setq char (char-before))) (t diff --git a/src/test.el b/src/test.el index 28b7db4..75398af 100644 --- a/src/test.el +++ b/src/test.el @@ -648,5 +648,28 @@ #'emmet-wrap-with-markup-test '((("div>ul>li" "I am some\nmultiline\n text") . "
\n \n
"))) +;; Regression test for #54 (broken emmet-find-left-bound behavior +;; after tag with attributes) +(defun emmet-regression-54-test (lis) + (let ((es (car lis)) + (emmet-preview-default nil) + (emmet-indent-after-insert nil)) + (with-temp-buffer + (emmet-mode 1) + (sgml-mode) + (insert "
") + (insert es) + (emmet-expand-line nil) + (buffer-string)))) + +(emmet-run-test-case "Regression 54 with span" + #'emmet-regression-54-test + '((("span") . "
"))) + +(emmet-run-test-case "Regression 54 with complex span" + #'emmet-regression-54-test + '((("span.whut[thing=\"stuff\"]{Huh?}") . "
Huh?"))) + + ;; start (emmet-test-cases) -- cgit v1.2.3