Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 748b884

Browse files
author
Marcel Gerber
committed
Code review changes
1 parent 22d9c59 commit 748b884

5 files changed

Lines changed: 48 additions & 18 deletions

File tree

src/extensions/default/CSSCodeHints/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ define(function (require, exports, module) {
185185
* @return {Array.jQuery} sorted Array of jQuery DOM elements to insert
186186
*/
187187
function formatHints(hints, query) {
188-
var hasColorSwatches = hints.some(function (token) {
188+
var hasColorSwatch = hints.some(function (token) {
189189
return token.color;
190190
});
191191

@@ -208,7 +208,7 @@ define(function (require, exports, module) {
208208
$hintObj.text(token.value);
209209
}
210210

211-
if (hasColorSwatches) {
211+
if (hasColorSwatch) {
212212
$hintObj = ColorUtils.formatColorHint($hintObj, token.color);
213213
}
214214

src/extensions/default/CSSCodeHints/unittests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ define(function (require, exports, module) {
8484
expect(provider.hasHints(testEditor, implicitChar)).toBe(true);
8585
var hintsObj = provider.getHints();
8686
expect(hintsObj).toBeTruthy();
87-
// return just the array of hints of returnWholeObj is falys
87+
// return just the array of hints if returnWholeObj is falsy
8888
return returnWholeObj ? hintsObj : extractHintList(hintsObj.hints);
8989
}
9090

@@ -688,7 +688,7 @@ define(function (require, exports, module) {
688688
expect(hints[0].find(".color-swatch").css("backgroundColor")).toBe("rgb(240, 248, 255)");
689689
});
690690

691-
it("should filter out color names appropiately", function () {
691+
it("should filter out color names appropriately", function () {
692692
testEditor.setCursorPos({ line: 100, ch: 27 }); // after border-left-color
693693
var hintList = expectHints(CSSCodeHints.cssPropHintProvider);
694694
verifyAttrHints(hintList, "deeppink"); // first hint should be deeppink

src/extensions/default/SVGCodeHints/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ define(function (require, exports, module) {
102102
* @return {Array.jQuery} sorted Array of jQuery DOM elements to insert
103103
*/
104104
function formatHints(hints, query) {
105-
var hasColorSwatches = hints.some(function (token) {
105+
var hasColorSwatch = hints.some(function (token) {
106106
return token.color;
107107
});
108108

@@ -125,7 +125,7 @@ define(function (require, exports, module) {
125125
$hintObj.text(token.value);
126126
}
127127

128-
if (hasColorSwatches) {
128+
if (hasColorSwatch) {
129129
$hintObj = ColorUtils.formatColorHint($hintObj, token.color);
130130
}
131131

src/extensions/default/SVGCodeHints/unittests.js

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ define(function (require, exports, module) {
3939
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" +
4040
" width=\"200\" height=\"200\" preserveAspectRatio=\"xMinYMin meet\">\n" +
4141
" <title>Brackets SVG Code Hints</title>\n" +
42-
" <rect width=\"200\" height=\"200\" baseline-shift=\"baseline\" alignment-baseline=\"alphabetic\" stroke-width=\"1\"></rect>\n" +
43-
" <rect width='160' height='160' x='20' y='20' baseline-shift='super' alignment-baseline='baseline' />\n" +
42+
" <rect width=\"200\" height=\"200\" baseline-shift=\"baseline\" alignment-baseline=\"alphabetic\" stroke-width=\"1\" color=\"\"></rect>\n" +
43+
" <rect width='160' height='160' x='20' y='20' baseline-shift='super' alignment-baseline='baseline' color='rent' fill='transparent' />\n" +
4444
" <g>\n" +
4545
" \n" +
4646
" </g>\n" +
@@ -205,7 +205,7 @@ define(function (require, exports, module) {
205205
expectNoHints(SVGCodeHints.hintProvider);
206206

207207
// Between <rect></rect>
208-
testEditor.setCursorPos({line: 4, ch: 110});
208+
testEditor.setCursorPos({line: 4, ch: 119});
209209
expectNoHints(SVGCodeHints.hintProvider);
210210

211211
// After <title>+space in <title> Brackets
@@ -216,21 +216,21 @@ define(function (require, exports, module) {
216216

217217
it("should not hint after the closed tag", function () {
218218
// After </rect>
219-
testEditor.setCursorPos({line: 4, ch: 117});
219+
testEditor.setCursorPos({line: 4, ch: 126});
220220
expectNoHints(SVGCodeHints.hintProvider);
221221

222222
// After space at </rect>+space
223-
testDocument.replaceRange(" ", {line: 4, ch: 117});
224-
testEditor.setCursorPos({line: 4, ch: 118});
223+
testDocument.replaceRange(" ", {line: 4, ch: 126});
224+
testEditor.setCursorPos({line: 4, ch: 127});
225225
expectNoHints(SVGCodeHints.hintProvider);
226226

227227
// After />
228-
testEditor.setCursorPos({line: 5, ch: 104});
228+
testEditor.setCursorPos({line: 5, ch: 136});
229229
expectNoHints(SVGCodeHints.hintProvider);
230230

231231
// After space in />+space
232-
testDocument.replaceRange(" ", {line: 5, ch: 104});
233-
testEditor.setCursorPos({line: 5, ch: 105});
232+
testDocument.replaceRange(" ", {line: 5, ch: 136});
233+
testEditor.setCursorPos({line: 5, ch: 137});
234234
expectNoHints(SVGCodeHints.hintProvider);
235235

236236
// After </g>
@@ -453,6 +453,38 @@ define(function (require, exports, module) {
453453
});
454454
});
455455

456+
describe("Color names and swatches", function () {
457+
it("should show color swatches", function () {
458+
// After color="
459+
testEditor.setCursorPos({line: 4, ch: 117});
460+
var hints = expectHints(SVGCodeHints.hintProvider);
461+
verifyHints(hints, "aliceblue"); // first hint should be aliceblue
462+
expect(hints[0].find(".color-swatch").length).toBe(1);
463+
expect(hints[0].find(".color-swatch").css("backgroundColor")).toBe("rgb(240, 248, 255)");
464+
});
465+
466+
it("should always include transparent and currentColor and they should not have a swatch, but class no-swatch-margin", function () {
467+
// After color='rent
468+
testEditor.setCursorPos({line: 5, ch: 113});
469+
var hints = expectHints(SVGCodeHints.hintProvider);
470+
verifyHints(hints, "currentColor"); // first hint should be currentColor
471+
expect(hints[0].find(".color-swatch").length).toBe(0); // no swatch for currentColor
472+
expect(hints[2].find(".color-swatch").length).toBe(0); // no swatch for transparent
473+
expect(hints[0].hasClass("no-swatch-margin")).toBeTruthy(); // no-swatch-margin applied to currentColor
474+
expect(hints[2].hasClass("no-swatch-margin")).toBeTruthy(); // no-swatch-margin applied to transparent
475+
});
476+
477+
it("should remove class no-swatch-margin from transparent if it's the only one in the list", function () {
478+
// After fill='transparent
479+
testEditor.setCursorPos({line: 5, ch: 132});
480+
var hints = expectHints(SVGCodeHints.hintProvider);
481+
verifyHints(hints, "transparent");
482+
expect(hints.length).toBe(1); // transparent should be the only hint
483+
expect(hints[0].find(".color-swatch").length).toBe(0); // no swatch for transparent
484+
expect(hints[0].hasClass("no-swatch-margin")).toBeFalsy(); // no-swatch-margin not applied to transparent
485+
});
486+
});
487+
456488
describe("Tag Insertion", function () {
457489
it("should insert if query is empty", function () {
458490
// After < inside <g>

src/styles/brackets_patterns_override.less

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,7 @@ a:focus {
532532
width: 12px;
533533
height: 12px;
534534
float: left;
535-
margin-top: 2px;
536-
margin-left: 4px;
537-
margin-right: -8px;
535+
margin: 2px -8px 0 4px;
538536
box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.24);
539537

540538
.dark & {

0 commit comments

Comments
 (0)