]> code.delx.au - gnu-emacs-elpa/commitdiff
Ignore trigger key prefixes that are shorter than symbol-at-point
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 1 Dec 2015 23:08:50 +0000 (01:08 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 1 Dec 2015 23:08:50 +0000 (01:08 +0200)
Closes #422

NEWS.md
company-yasnippet.el

diff --git a/NEWS.md b/NEWS.md
index fbbd3c3841571e084c8308e7aec175c986c65c3f..6e92cce574ff596951004493efb5653aadb4a6b5 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,8 +2,11 @@
 
 ## Next
 
 
 ## Next
 
-* `company-yasnippet` respects `yas-key-syntaxes`. But we use them in the
-  reverse order, preferring the longest key prefix that matches anything.
+* `company-yasnippet` supports `yas-key-syntaxes` better. But we use them in the
+  reverse order, preferring the longest key prefix that matches anything. And we
+  only consider trigger key prefixes that are at least as long as the symbol at
+  point, which effectively means skipping the `"w"` element
+  ([#422](https://github.com/company-mode/company-mode/issues/422)).
 * New user option `company-search-regexp-function`.
 * Completion is not started automatically when a keyboard macro is being
   recorded ([#374](https://github.com/company-mode/company-mode/issues/374)).
 * New user option `company-search-regexp-function`.
 * Completion is not started automatically when a keyboard macro is being
   recorded ([#374](https://github.com/company-mode/company-mode/issues/374)).
index 93e6eb299e250d4b2a9df4298be64a637752bd63..e5fded4d19e27811402d754c79a2b76afea984a9 100644 (file)
@@ -67,6 +67,8 @@
   ;; matches, so the longest prefix with any matches should be the most useful.
   (cl-loop with tables = (yas--get-snippet-tables)
            for key-prefix in (company-yasnippet--key-prefixes)
   ;; matches, so the longest prefix with any matches should be the most useful.
   (cl-loop with tables = (yas--get-snippet-tables)
            for key-prefix in (company-yasnippet--key-prefixes)
+           ;; Only consider keys at least as long as the symbol at point.
+           when (>= (length key-prefix) (length prefix))
            thereis (company-yasnippet--completions-for-prefix prefix
                                                               key-prefix
                                                               tables)))
            thereis (company-yasnippet--completions-for-prefix prefix
                                                               key-prefix
                                                               tables)))
                   (propertize key
                               'yas-annotation name
                               'yas-template template
                   (propertize key
                               'yas-annotation name
                               'yas-template template
-                              'yas-prefix-offset
-                              (let ((pl (length prefix))
-                                    (kpl (length key-prefix)))
-                                (if (> kpl pl)
-                                    (- kpl pl)
-                                  0)))
+                              'yas-prefix-offset (- (length key-prefix)
+                                                    (length prefix)))
                   res))
                value)))
           keyhash))
                   res))
                value)))
           keyhash))