From 8960f6aa36000a8d6014e0c7371ee96ba148965a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Simen=20Heggest=C3=B8yl?= Date: Sat, 17 Jun 2017 09:28:43 +0200 Subject: [PATCH] Complete CSS property values less eagerly (Bug#27392) * lisp/textmodes/css-mode.el (css--complete-property-value): Be less eager by looking for a colon after the property which values are being completed for. * test/lisp/textmodes/css-mode-tests.el (css-test-complete-property): Add a test case ensuring that properties that are prefixes of other properties don't hinder further completion. --- lisp/textmodes/css-mode.el | 9 +++++---- test/lisp/textmodes/css-mode-tests.el | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 0beaaaa32f1..4952533e834 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1289,10 +1289,11 @@ the string PROPERTY." (let ((property (save-excursion (re-search-backward ":[^/]" (line-beginning-position) t) - (let ((property-end (point))) - (skip-chars-backward "-[:alnum:]") - (let ((property (buffer-substring (point) property-end))) - (car (member property css-property-ids))))))) + (when (eq (char-after) ?:) + (let ((property-end (point))) + (skip-chars-backward "-[:alnum:]") + (let ((prop (buffer-substring (point) property-end))) + (car (member prop css-property-ids)))))))) (when property (let ((end (point))) (save-excursion diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index b4666ae72d7..68946a01c06 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -159,7 +159,12 @@ (insert "body { f") (let ((completions (css-mode-tests--completions))) (should (member "filter" completions)) - (should-not (member "position" completions))))) + (should-not (member "position" completions)))) + ;; Bug#27392 + (with-temp-buffer + (css-mode) + (insert "html { grid") + (should (> (length (css-mode-tests--completions)) 0)))) (ert-deftest css-test-foreign-completions () (let ((other-buffer-1 (generate-new-buffer "1")) -- 2.39.2