From 6083965958381b29aa55948670d2b85289b0be6d Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 9 Apr 2015 10:51:23 -0400 Subject: [PATCH] css-mode.el (css-smie-rules): Fix indentation after complex selectors Fixes: debbugs:20282 * lisp/textmodes/css-mode.el (css-smie-rules): Don't get confused by inner structure of selectors. --- lisp/textmodes/css-mode.el | 4 ++++ test/indent/css-mode.css | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 72800808e65..851618cfccc 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -327,6 +327,10 @@ (`(:elem . basic) css-indent-offset) (`(:elem . arg) 0) (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467). + (`(:before . "{") + (when (smie-rule-hanging-p) + (smie-backward-sexp ";") + (smie-indent-virtual))) (`(:before . ,(or "{" "(")) (if (smie-rule-hanging-p) (smie-rule-parent 0))))) diff --git a/test/indent/css-mode.css b/test/indent/css-mode.css index 564ac16f954..faf91539d84 100644 --- a/test/indent/css-mode.css +++ b/test/indent/css-mode.css @@ -8,6 +8,21 @@ article[role="main"] { width: 60%; } +a, b:hover, c { + color: black; +} + +a, b:hover { /* bug:20282 */ + c { + color: black; + } + color: black; +} + +a.b:c,d.e:f,g[h]:i,j[k]:l,.m.n:o,.p.q:r,.s[t]:u,.v[w]:x { /* bug:20282 */ + background-color: white; +} + /* asdfasdf */ @foo x2 { bla:toto; -- 2.39.2