]> code.delx.au - gnu-emacs-elpa/commitdiff
company-template-c-like-templatify: Remove text after the closing paren
authorDmitry Gutov <dgutov@yandex.ru>
Sat, 17 Aug 2013 12:52:06 +0000 (15:52 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Sat, 17 Aug 2013 12:52:25 +0000 (15:52 +0300)
#31

company-template.el
company-tests.el

index 6ffd648f37f298605e3fe1dc857508dd49837922..5c72ac8bbff0c39c4124920c3f00363071f0e255 100644 (file)
@@ -150,6 +150,8 @@ Leave point at the end of the field."
   (let* ((end (point-marker))
          (beg (- (point) (length call)))
          (cnt 0))
+    (when (re-search-backward ")" beg t)
+      (delete-region (match-end 0) end))
     (goto-char beg)
     (when (search-forward "(" end 'move)
       (if (eq (char-after) ?\))
index 9f0e70db4bfa184863fa7d1d5e3d8462392986cd..79d1f0257e9180ae2c8a6f7427f28bd9bbced347 100644 (file)
       (should (equal "int a"
                      (overlay-get (company-template-field-at) 'display))))))
 
+(ert-deftest company-template-c-like-templatify-trims-after-closing-paren ()
+  (with-temp-buffer
+    (let ((text "foo(int a, short b)!@ #1334 a"))
+      (insert text)
+      (company-template-c-like-templatify text)
+      (should (equal "foo(arg0, arg1)" (buffer-string)))
+      (should (looking-at "arg0")))))
+
 ;;; Elisp
 
 (defmacro company-elisp-with-buffer (contents &rest body)