Skip to content

Commit 98dab1a

Browse files
authored
Merge pull request #78 from adobe/release
adobe/release merge for 1.8.4
2 parents a46c522 + 3af64fa commit 98dab1a

File tree

21 files changed

+617
-172
lines changed

21 files changed

+617
-172
lines changed

src/editor/CodeHintList.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,17 @@ define(function (require, exports, module) {
392392
if (event.type === "keydown" && this.isHandlingKeyCode(event)) {
393393
keyCode = event.keyCode;
394394

395-
if (event.keyCode === KeyEvent.DOM_VK_ESCAPE ||
396-
(event.shiftKey &&
395+
if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) {
396+
event.stopImmediatePropagation();
397+
this.handleClose();
398+
399+
return false;
400+
} else if (event.shiftKey &&
397401
(event.keyCode === KeyEvent.DOM_VK_UP ||
398402
event.keyCode === KeyEvent.DOM_VK_DOWN ||
399403
event.keyCode === KeyEvent.DOM_VK_PAGE_UP ||
400-
event.keyCode === KeyEvent.DOM_VK_PAGE_DOWN))) {
404+
event.keyCode === KeyEvent.DOM_VK_PAGE_DOWN)) {
401405
this.handleClose();
402-
403406
// Let the event bubble.
404407
return false;
405408
} else if (keyCode === KeyEvent.DOM_VK_UP) {

src/editor/Editor.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,11 @@ define(function (require, exports, module) {
10481048
*/
10491049
Editor.prototype._resetText = function (text) {
10501050
var currentText = this._codeMirror.getValue();
1051-
if (text === currentText) {
1051+
1052+
// compare with ignoring line-endings, issue #11826
1053+
var textLF = text ? text.replace(/(\r\n|\r|\n)/g, "\n") : null;
1054+
var currentTextLF = currentText ? currentText.replace(/(\r\n|\r|\n)/g, "\n") : null;
1055+
if (textLF === currentTextLF) {
10521056
// there's nothing to reset
10531057
return;
10541058
}

src/extensibility/ExtensionManagerDialog.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ define(function (require, exports, module) {
309309
views = [],
310310
$search,
311311
$searchClear,
312+
$modalDlg,
312313
context = { Strings: Strings, showRegistry: !!brackets.config.extension_registry },
313314
models = [];
314315

@@ -335,6 +336,7 @@ define(function (require, exports, module) {
335336
$search.val("");
336337
views.forEach(function (view, index) {
337338
view.filter("");
339+
$modalDlg.scrollTop(0);
338340
});
339341

340342
if (!updateSearchDisabled()) {
@@ -360,14 +362,15 @@ define(function (require, exports, module) {
360362
$dlg = dialog.getElement();
361363
$search = $(".search", $dlg);
362364
$searchClear = $(".search-clear", $dlg);
365+
$modalDlg = $(".modal-body", $dlg);
363366

364367
function setActiveTab($tab) {
365368
if (models[_activeTabIndex]) {
366-
models[_activeTabIndex].scrollPos = $(".modal-body", $dlg).scrollTop();
369+
models[_activeTabIndex].scrollPos = $modalDlg.scrollTop();
367370
}
368371
$tab.tab("show");
369372
if (models[_activeTabIndex]) {
370-
$(".modal-body", $dlg).scrollTop(models[_activeTabIndex].scrollPos || 0);
373+
$modalDlg.scrollTop(models[_activeTabIndex].scrollPos || 0);
371374
clearSearch();
372375
}
373376
}
@@ -434,7 +437,7 @@ define(function (require, exports, module) {
434437
$(".spinner", $dlg).remove();
435438

436439
views.forEach(function (view) {
437-
view.$el.appendTo($(".modal-body", $dlg));
440+
view.$el.appendTo($modalDlg);
438441
});
439442

440443
// Update search UI before new tab is shown
@@ -454,6 +457,7 @@ define(function (require, exports, module) {
454457
var query = $(this).val();
455458
views.forEach(function (view) {
456459
view.filter(query);
460+
$modalDlg.scrollTop(0);
457461
});
458462
}).on("click", ".search-clear", clearSearch);
459463

src/extensions/default/CSSCodeHints/CSSProperties.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"flow-into": {"values": ["none"], "type": "named-flow"},
9696
"flow-from": {"values": ["none", "inherit"], "type": "named-flow"},
9797
"font": {"values": []},
98+
"font-display": {"values": ["auto", "block", "swap", "fallback", "optional"]},
9899
"font-family": {"values": ["cursive", "fantasy", "inherit", "monospace", "sans-serif", "serif"]},
99100
"font-feature-settings": {"values": ["normal"]},
100101
"font-kerning": {"values": ["auto", "none", "normal"]},
@@ -112,6 +113,23 @@
112113
"font-variant-numeric": {"values": ["normal"]},
113114
"font-variant-position": {"values": ["normal", "sub", "super"]},
114115
"font-weight": {"values": ["bold", "bolder", "lighter", "normal", "100", "200", "300", "400", "500", "600", "700", "800", "900", "inherit"]},
116+
"grid": {"values": []},
117+
"grid-area": {"values": []},
118+
"grid-auto-columns": {"values": []},
119+
"grid-auto-flow": {"values": ["row", "column", "dense"]},
120+
"grid-auto-rows": {"values": []},
121+
"grid-column": {"values": ["auto"]},
122+
"grid-column-end": {"values": []},
123+
"grid-column-gap": {"values": []},
124+
"grid-column-start": {"values": []},
125+
"grid-gap": {"values": []},
126+
"grid-row": {"values": ["auto"]},
127+
"grid-row-end": {"values": []},
128+
"grid-row-start": {"values": []},
129+
"grid-row-gap": {"values": []},
130+
"grid-template-areas": {"values": []},
131+
"grid-template-columns": {"values": ["auto"]},
132+
"grid-template-rows": {"values": ["auto"]},
115133
"height": {"values": ["auto", "inherit"]},
116134
"hyphens": {"values": ["auto", "manual", "none"]},
117135
"image-orientation": {"values": []},
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/*
2+
* Copyright (c) 2016 - present Adobe Systems Incorporated. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*
22+
*/
23+
24+
/**
25+
* Fold range finder for handlebars/mustache template type files.
26+
* @author Patrick Oladimeji
27+
* @date 14/08/2016 22:04:21
28+
*/
29+
30+
define(function (require, exports, module) {
31+
"use strict";
32+
var CodeMirror = brackets.getModule("thirdparty/CodeMirror/lib/codemirror"),
33+
_ = brackets.getModule("thirdparty/lodash"),
34+
StringUtils = brackets.getModule("utils/StringUtils");
35+
36+
/**
37+
* Utility function for scanning the text in a document until a certain condition is met
38+
* @param {object} cm The code mirror object representing the document
39+
* @param {string} startCh The start character position for the scan operation
40+
* @param {number} startLine The start line position for the scan operation
41+
* @param {function (string): boolean} condition A predicate function that takes in the text seen so far and returns true if the scanning process should be halted
42+
* @returns {{from:CodeMirror.Pos, to: CodeMirror.Pos, string: string}} An object representing the range of text scanned.
43+
*/
44+
function scanTextUntil(cm, startCh, startLine, condition) {
45+
var line = cm.getLine(startLine),
46+
seen = "",
47+
characterIndex = startCh,
48+
currentLine = startLine,
49+
range;
50+
while (currentLine <= cm.lastLine()) {
51+
if (line.length === 0) {
52+
characterIndex = 0;
53+
line = cm.getLine(++currentLine);
54+
} else {
55+
seen = seen.concat(line[characterIndex] || "");
56+
if (condition(seen)) {
57+
range = {
58+
from: {ch: startCh, line: startLine},
59+
to: {ch: characterIndex, line: currentLine},
60+
string: seen
61+
};
62+
return range;
63+
} else if (characterIndex >= line.length) {
64+
seen = seen.concat(cm.lineSeparator());
65+
if (condition(seen)) {
66+
range = {
67+
from: {ch: startCh, line: startLine},
68+
to: {ch: characterIndex, line: currentLine},
69+
string: seen
70+
};
71+
return range;
72+
}
73+
characterIndex = 0;
74+
line = cm.getLine(++currentLine);
75+
} else {
76+
++characterIndex;
77+
}
78+
}
79+
}
80+
}
81+
82+
/**
83+
* Utility function used to detect the end of a helper name when scanning a series of text.
84+
* The end of a helper name is signalled by a space character or the `}`
85+
* @param {string} seen The string seen so far
86+
* @returns {boolean} True when the end of a helper name has been detected.
87+
*/
88+
function endHelperName(seen) {
89+
return (/\s$/).test(seen) || StringUtils.endsWith(seen, "}");
90+
}
91+
92+
/**
93+
* Returns a predicate function that returns true when a specific character is found
94+
* @param {string} character the character to use in the match function
95+
* @returns {function} A function that checks if the last character of the parameter string matches the parameter character
96+
*/
97+
function readUntil(character) {
98+
return function (seen) {
99+
return seen[seen.length - 1] === character;
100+
};
101+
}
102+
103+
function getRange(cm, start) {
104+
var currentLine = start.line,
105+
text = cm.getLine(currentLine) || "",
106+
i = 0,
107+
tagStack = [],
108+
braceStack = [],
109+
found,
110+
openTag,
111+
openPos,
112+
currentCharacter,
113+
openTagIndex = text.indexOf("{{"),
114+
range;
115+
116+
if (openTagIndex < 0 || text[openTagIndex + 2] === "/") {
117+
return;
118+
}
119+
120+
found = scanTextUntil(cm, openTagIndex + 2, currentLine, endHelperName);
121+
if (!found) {
122+
return;
123+
}
124+
125+
openPos = {
126+
from: {line: currentLine, ch: openTagIndex},
127+
to: found.to
128+
};
129+
openTag = found.string.substring(0, found.string.length - 1);
130+
if (openTag[0] === "#" || openTag[0] === "~" || openTag[0] === "^") {
131+
found = scanTextUntil(cm, openPos.to.ch, openPos.to.line, function (seen) {
132+
return seen.length > 1 && seen.substr(-2) === "}}";
133+
});
134+
if (found) {
135+
openPos.to = {line: found.to.line, ch: found.to.ch + 1};
136+
}
137+
tagStack.push(openTag.substr(1));
138+
} else {
139+
braceStack.push("{{");
140+
}
141+
142+
i = found.to.ch;
143+
currentLine = found.to.line;
144+
145+
while (currentLine <= cm.lastLine()) {
146+
text = cm.getLine(currentLine);
147+
currentCharacter = (text && text[i]) || "";
148+
switch (currentCharacter) {
149+
case "{":
150+
if (text[i + 1] === "{") {
151+
found = scanTextUntil(cm, i + 2, currentLine, endHelperName);
152+
if (found) {
153+
var tag = found.string.substring(0, found.string.length - 1);
154+
if (tag[0] === "#" || tag[0] === "~" || tag[0] === "^") {
155+
tagStack.push(tag.substr(1));
156+
} else if (tag[0] === "/" &&
157+
(_.last(tagStack) === tag.substr(1) || _.last(tagStack) === "*" + tag.substr(1))) {
158+
tagStack.pop();
159+
if (tagStack.length === 0 && braceStack.length === 0) {
160+
range = {
161+
from: openPos.to,
162+
to: {ch: i, line: currentLine}
163+
};
164+
return range;
165+
}
166+
} else {
167+
braceStack.push("{{");
168+
}
169+
}
170+
}
171+
break;
172+
case "}":
173+
if (text[i + 1] === "}") {
174+
braceStack.pop();
175+
if (braceStack.length === 0 && tagStack.length === 0) {
176+
range = {
177+
from: openPos.to,
178+
to: {ch: i, line: currentLine}
179+
};
180+
return range;
181+
}
182+
}
183+
break;
184+
case "\"":
185+
case "'":
186+
found = scanTextUntil(cm, i + 1, currentLine, readUntil(text[i]));
187+
if (found) {
188+
i = found.to.ch;
189+
currentLine = found.to.line;
190+
}
191+
break;
192+
default:
193+
break;
194+
}
195+
196+
++i;
197+
if (i >= text.length) {
198+
++currentLine;
199+
i = 0;
200+
}
201+
}
202+
}
203+
204+
module.exports = getRange;
205+
});

src/extensions/default/CodeFolding/main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ define(function (require, exports, module) {
6868
var foldGutter = require("foldhelpers/foldgutter"),
6969
foldCode = require("foldhelpers/foldcode"),
7070
indentFold = require("foldhelpers/indentFold"),
71+
handlebarsFold = require("foldhelpers/handlebarsFold"),
7172
selectionFold = require("foldhelpers/foldSelected");
7273

7374

@@ -393,8 +394,9 @@ define(function (require, exports, module) {
393394
return prefs.getSetting("alwaysUseIndentFold");
394395
}, indentFold);
395396

396-
CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace);
397-
CodeMirror.registerHelper("fold", "tornado", CodeMirror.helpers.fold.brace);
397+
CodeMirror.registerHelper("fold", "handlebars", handlebarsFold);
398+
CodeMirror.registerHelper("fold", "htmlhandlebars", handlebarsFold);
399+
CodeMirror.registerHelper("fold", "htmlmixed", handlebarsFold);
398400

399401
EditorManager.on("activeEditorChange.CodeFolding", onActiveEditorChanged);
400402
DocumentManager.on("documentRefreshed.CodeFolding", function (event, doc) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{!--
2+
comments
3+
go
4+
here
5+
--}}
6+
7+
{{#test}}
8+
9+
10+
{{/test}}
11+
12+
<h1>Comments</h1>
13+
14+
<div id="comments">
15+
16+
{{#each comments}}
17+
{{../permalink
18+
19+
}}
20+
21+
{{#if title}}
22+
{{../permalink}}
23+
{{/if}}
24+
{{/each}}
25+
26+
{{#each comments}}
27+
<h2><a href="/posts/{{../permalink}}#{{id}}">{{title}}</a></h2>
28+
<div>
29+
{{
30+
body
31+
}}
32+
<section class="person">
33+
{{~person}}
34+
<div>Name: {{firstName}} {{lastName}}</div>
35+
<div>Email: {{email}}</div>
36+
<div>Phone: {{phone}}</div>
37+
{{/person}}
38+
{{#*inline "myPartial"}}
39+
My Content
40+
{{/inline}}
41+
{{^relationships}}
42+
Relationship details go here
43+
{{/relationships}}
44+
</section>
45+
</div>
46+
{{/each}}
47+
</div>

0 commit comments

Comments
 (0)