diff --git a/src/extensions/default/UrlCodeHints/main.js b/src/extensions/default/UrlCodeHints/main.js index 0a60c0db2d5..b90f49250f3 100644 --- a/src/extensions/default/UrlCodeHints/main.js +++ b/src/extensions/default/UrlCodeHints/main.js @@ -42,7 +42,8 @@ define(function (require, exports, module) { urlHints, data, - htmlAttrs; + htmlAttrs, + styleModes = ["css", "text/x-less", "text/x-scss"]; /** * @constructor @@ -263,7 +264,7 @@ define(function (require, exports, module) { var mode = editor.getModeForSelection(); if (mode === "html") { return this.hasHtmlHints(editor, implicitChar); - } else if (mode === "css") { + } else if (styleModes.indexOf(mode) > -1) { return this.hasCssHints(editor, implicitChar); } @@ -422,7 +423,7 @@ define(function (require, exports, module) { } this.info = tagInfo; - } else if (mode === "css") { + } else if (styleModes.indexOf(mode) > -1) { this.info = CSSUtils.getInfoAtPos(this.editor, cursor); var context = this.info.context; @@ -538,7 +539,7 @@ define(function (require, exports, module) { if (mode === "html") { return this.insertHtmlHint(completion); - } else if (mode === "css") { + } else if (styleModes.indexOf(mode) > -1) { return this.insertCssHint(completion); } @@ -810,7 +811,7 @@ define(function (require, exports, module) { htmlAttrs = data.htmlAttrs; urlHints = new UrlCodeHints(); - CodeHintManager.registerHintProvider(urlHints, ["css", "html"], 5); + CodeHintManager.registerHintProvider(urlHints, ["css", "html", "less", "scss"], 5); FileSystem.on("change", _clearCachedHints); FileSystem.on("rename", _clearCachedHints); diff --git a/src/extensions/default/UrlCodeHints/testfiles/subfolder/test.scss b/src/extensions/default/UrlCodeHints/testfiles/subfolder/test.scss new file mode 100644 index 00000000000..bbbb0f10e64 --- /dev/null +++ b/src/extensions/default/UrlCodeHints/testfiles/subfolder/test.scss @@ -0,0 +1,8 @@ +/* test.scss */ +body { + .test { + &.brackets { + background-image: url(); + } + } +} diff --git a/src/extensions/default/UrlCodeHints/unittests.js b/src/extensions/default/UrlCodeHints/unittests.js index d471a413e92..6cc690005cf 100644 --- a/src/extensions/default/UrlCodeHints/unittests.js +++ b/src/extensions/default/UrlCodeHints/unittests.js @@ -41,6 +41,7 @@ define(function (require, exports, module) { var extensionPath = FileUtils.getNativeModuleDirectoryPath(module), testHtmlPath = extensionPath + "/testfiles/test.html", testCssPath = extensionPath + "/testfiles/subfolder/test.css", + testScssPath = extensionPath + "/testfiles/subfolder/test.scss", testDocument, testEditor, hintsObj; @@ -50,7 +51,7 @@ define(function (require, exports, module) { // strategically so that they sort the same on all OS's (i.e. folders are listed // first, and then files), but this is not true for UrlCodeHints folder. var testfilesDirHints = [ "subfolder/", "test.html"], - subfolderDirHints = [ "chevron.png", "test.css", "test.js"], + subfolderDirHints = [ "chevron.png", "test.css", "test.js", "test.scss"], UrlCodeHintsDirHintsMac = [ "../data.json", "../main.js", "../testfiles/", "../unittests.js"], UrlCodeHintsDirHints = [ "../testfiles/", "../data.json", "../main.js", "../unittests.js"]; @@ -269,15 +270,15 @@ define(function (require, exports, module) { describe("Url Code Hints in a subfolder", function () { - beforeFirst(function () { - setupTests(testCssPath); - }); - - afterLast(function () { + afterEach(function () { tearDownTests(); }); - it("should hint for background-image: url()", function () { + it("should hint for background-image: url() in CSS", function () { + runs(function () { + setupTests(testCssPath); + }); + runs(function () { testEditor.setCursorPos({ line: 3, ch: 26 }); hintsObj = null; @@ -288,6 +289,22 @@ define(function (require, exports, module) { verifyUrlHints(hintsObj.hints, subfolderDirHints); }); }); + + it("should hint for background-image: url() in SCSS", function () { + runs(function () { + setupTests(testScssPath); + }); + + runs(function () { + testEditor.setCursorPos({ line: 4, ch: 34 }); + hintsObj = null; + expectAsyncHints(UrlCodeHints.hintProvider); + }); + + runs(function () { + verifyUrlHints(hintsObj.hints, subfolderDirHints); + }); + }); }); describe("Project root relative Url Code Hints", function () { @@ -471,7 +488,7 @@ define(function (require, exports, module) { runs(function () { expect(hintsObj).toBeTruthy(); expect(hintsObj.hints).toBeTruthy(); - expect(hintsObj.hints.length).toBe(3); + expect(hintsObj.hints.length).toBe(subfolderDirHints.length); // Complete path is displayed expect(hintsObj.hints[0]).toBe("subfolder/chevron.png"); @@ -526,7 +543,7 @@ define(function (require, exports, module) { runs(function () { expect(hintsObj).toBeTruthy(); expect(hintsObj.hints).toBeTruthy(); - expect(hintsObj.hints.length).toBe(3); + expect(hintsObj.hints.length).toBe(subfolderDirHints.length); // Complete path is displayed expect(hintsObj.hints[0]).toBe("subfolder/chevron.png"); @@ -578,7 +595,7 @@ define(function (require, exports, module) { runs(function () { expect(hintsObj).toBeTruthy(); expect(hintsObj.hints).toBeTruthy(); - expect(hintsObj.hints.length).toBe(3); + expect(hintsObj.hints.length).toBe(subfolderDirHints.length); // Complete path is displayed expect(hintsObj.hints[0]).toBe("subfolder/chevron.png"); @@ -675,7 +692,7 @@ define(function (require, exports, module) { runs(function () { expect(hintsObj).toBeTruthy(); expect(hintsObj.hints).toBeTruthy(); - expect(hintsObj.hints.length).toBe(3); + expect(hintsObj.hints.length).toBe(subfolderDirHints.length); // Complete path is displayed expect(hintsObj.hints[0]).toBe("subfolder/chevron.png");