Closes #474: fix more cc-mode font-lock conflicts

* yasnippet-tests.el (example-for-issue-474): Don't call insert from
  within backquotes, it's redundant and prevents proper testing of
  backquote expansion.

* yasnippet.el (yas--restore-backquotes, yas--save-backquotes): Ensure
  the buffer isn't narrowed while modifying it to avoid conflicting with
  cc-mode fontification.
This commit is contained in:
Noam Postavsky 2014-05-14 19:49:11 -04:00
parent fe288a156c
commit 763f5faa14
2 changed files with 11 additions and 7 deletions

View File

@ -229,7 +229,7 @@
(c-mode) (c-mode)
(yas-minor-mode 1) (yas-minor-mode 1)
(insert "#include <foo>\n") (insert "#include <foo>\n")
(let ((yas-good-grace nil)) (yas-expand-snippet "`(insert \"TODO: \")`")) (let ((yas-good-grace nil)) (yas-expand-snippet "`\"TODO: \"`"))
(should (string= (yas--buffer-contents) "#include <foo>\nTODO: ")))) (should (string= (yas--buffer-contents) "#include <foo>\nTODO: "))))
(ert-deftest example-for-issue-404 () (ert-deftest example-for-issue-404 ()

View File

@ -3911,9 +3911,11 @@ with their evaluated value into `yas--backquote-markers-and-strings'."
(goto-char (match-beginning 0)) (goto-char (match-beginning 0))
(when transformed (when transformed
(let ((marker (make-marker))) (let ((marker (make-marker)))
(insert "Y") ;; quite horrendous, I love it :) (save-restriction
(set-marker marker (point)) (widen)
(insert "Y") (insert "Y") ;; quite horrendous, I love it :)
(set-marker marker (point))
(insert "Y"))
(push (cons marker transformed) yas--backquote-markers-and-strings)))))) (push (cons marker transformed) yas--backquote-markers-and-strings))))))
(defun yas--restore-backquotes () (defun yas--restore-backquotes ()
@ -3924,9 +3926,11 @@ with their evaluated value into `yas--backquote-markers-and-strings'."
(string (cdr marker-and-string))) (string (cdr marker-and-string)))
(save-excursion (save-excursion
(goto-char marker) (goto-char marker)
(delete-char -1) (save-restriction
(insert string) (widen)
(delete-char 1) (delete-char -1)
(insert string)
(delete-char 1))
(set-marker marker nil))))) (set-marker marker nil)))))
(defun yas--scan-sexps (from count) (defun yas--scan-sexps (from count)