From da3b2ecdcae09d556bb2323a98b3ea10c0093f62 Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Sat, 24 Aug 2013 17:04:47 -0700 Subject: [PATCH 1/2] Show CSS code hints in SCSS mode. --- src/extensions/default/CSSCodeHints/main.js | 2 +- src/language/CSSUtils.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/extensions/default/CSSCodeHints/main.js b/src/extensions/default/CSSCodeHints/main.js index ec54c79903a..6342f0e735d 100644 --- a/src/extensions/default/CSSCodeHints/main.js +++ b/src/extensions/default/CSSCodeHints/main.js @@ -305,7 +305,7 @@ define(function (require, exports, module) { AppInit.appReady(function () { var cssPropHints = new CssPropHints(); - CodeHintManager.registerHintProvider(cssPropHints, ["css"], 0); + CodeHintManager.registerHintProvider(cssPropHints, ["css", "scss"], 0); // For unit testing exports.cssPropHintProvider = cssPropHints; diff --git a/src/language/CSSUtils.js b/src/language/CSSUtils.js index 59a3309cf88..71c654b53e3 100644 --- a/src/language/CSSUtils.js +++ b/src/language/CSSUtils.js @@ -73,7 +73,7 @@ define(function (require, exports, module) { } lastToken = state.stack[state.stack.length - 1]; - return (lastToken === "{" || lastToken === "rule"); + return (lastToken === "{" || lastToken === "rule" || lastToken === "block"); } /** @@ -94,7 +94,8 @@ define(function (require, exports, module) { if (!state.stack || state.stack.length < 2) { return false; } - return (state.stack[state.stack.length - 1] === "propertyValue" && state.stack[state.stack.length - 2] === "rule"); + return (state.stack[state.stack.length - 1] === "propertyValue" && + (state.stack[state.stack.length - 2] === "rule" || state.stack[state.stack.length - 2] === "block")); } /** @@ -450,7 +451,7 @@ define(function (require, exports, module) { mode = editor.getModeForSelection(); // Check if this is inside a style block or in a css/less document. - if (mode !== "css" && mode !== "less") { + if (mode !== "css" && mode !== "text/x-scss" && mode !== "less") { return createInfo(); } From 8434cc4d1e6374dc2190d13296c8bd3f22c7347a Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Wed, 4 Sep 2013 09:21:46 -0700 Subject: [PATCH 2/2] Fix unit tests failures casued by CodeMirror token stack change for CSS property values in function notation. --- src/language/CSSUtils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/language/CSSUtils.js b/src/language/CSSUtils.js index 71c654b53e3..e7d09d0ef18 100644 --- a/src/language/CSSUtils.js +++ b/src/language/CSSUtils.js @@ -94,8 +94,9 @@ define(function (require, exports, module) { if (!state.stack || state.stack.length < 2) { return false; } - return (state.stack[state.stack.length - 1] === "propertyValue" && - (state.stack[state.stack.length - 2] === "rule" || state.stack[state.stack.length - 2] === "block")); + return ((state.stack[state.stack.length - 1] === "propertyValue" && + (state.stack[state.stack.length - 2] === "rule" || state.stack[state.stack.length - 2] === "block")) || + (state.stack[state.stack.length - 1] === "(" && (state.stack[state.stack.length - 2] === "propertyValue"))); } /**