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

Commit 0b51f5c

Browse files
committed
Merge remote-tracking branch 'origin/master' into pflynn/block-comment-unittests
* origin/master: (154 commits) Made ContextMenu actually call its superclass constructor (instead of assigning a new menu to this.menu, which isn't actually used). Increase test timeout when requesting a native file system for a drive. Code review: add testcase for nonempty invalid regex; remove unneeded JS dependency. Align equals signs Code review cleanups Code review cleanups rename back to copyPath() fix jslint errors code review comments more code review comments Small jsdoc fix in _fsErrorToDOMErrorName For #2310, consider an empty line number query valid, but show error if the line number is out of range of the editor code review comments Use scrollTop instead of scrollIntoView for #2130 Add a few more unit tests for Find. Update unit-test harness files to include this suite. Rename _nativeToFileError to _fsErrorToDOMErrorName Increase timeout when waiting for a new NativeFileSystem to be created. Global FileError.* and error.code refactor External NativeFileError Fix jsdocs and change _nativeToFileError signature ...
2 parents 759656a + 00c5e6d commit 0b51f5c

102 files changed

Lines changed: 4435 additions & 1596 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ src/extensions/disabled
1111

1212
#OSX .DS_Store files
1313
.DS_Store
14+
15+
# unit test working directory
16+
test/temp

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
Welcome to Brackets!
22
-------------------
33

4-
This is a very early version of Brackets, a code editor for HTML, CSS
4+
This is an early version of Brackets, a code editor for HTML, CSS
55
and JavaScript that's *built* in HTML, CSS and JavaScript.
66

77
What makes Brackets different from other web code editors?
88
* **Tools shouldn't get in your way.** Instead of cluttering up your coding
99
environment with lots of panels and icons, the Quick Edit UI in Brackets puts
1010
context-specific code and tools inline.
1111
* **Brackets is in sync with your browser.** With Live Development, Brackets
12-
works directly with your browser to push code edits instantly, set breakpoints,
13-
and jump back and forth between your real source code and the browser view.
12+
works directly with your browser to push code edits instantly and jump
13+
back and forth between your real source code and the browser view.
1414
* **Do it yourself.** Because Brackets is open source, and built with HTML, CSS
1515
and JavaScript, you can help build the best code editor for the web.
1616

1717
You can see some
1818
[screenshots of Brackets](https://github.com/adobe/brackets/wiki/Brackets-Screenshots)
1919
on the wiki.
2020

21-
Brackets is *very* early in development, so many of the features you would
21+
Brackets is early in development, so many of the features you would
2222
expect in a code editor are missing, and some existing features might be
2323
incomplete or not as useful as you'd want. But if you like the direction
2424
it's going, please contribute!
@@ -32,7 +32,7 @@ for info on upcoming things we're planning to contribute to CodeMirror.
3232
How to run Brackets
3333
-------------------
3434

35-
**Brackets isn't ready for general use yet.** It's still *very* early in
35+
**Brackets isn't ready for general use yet.** It's still early in
3636
development, is missing a lot of basic editor features, and *probably*
3737
has bugs. That said, we've actually been using Brackets to develop Brackets
3838
for awhile now, so what's there is reasonably stable.
@@ -43,9 +43,11 @@ application in a thin native shell, so that it can access your local files.
4343
The native shell for Brackets lives in a separate repo,
4444
[adobe/brackets-shell](https://github.com/adobe/brackets-shell/).
4545

46-
The Brackets native shell currently runs on Mac and Windows. Since it's based on
47-
CEF/Chromium, it could be ported to Linux relatively easily, but that work hasn't
48-
been done yet. Stay tuned.
46+
The Brackets native shell currently runs on Mac and Windows.
47+
The community has started working on a Linux port, and is making great progress;
48+
if you're interested, check out the
49+
[discussion thread](https://groups.google.com/forum/?fromgroups=#!topic/brackets-dev/29vOJ6tvl8A)
50+
on the brackets-dev Google Group.
4951

5052
You can download "stable" builds of Brackets from the **Download Packages** section of the
5153
[downloads page](http://github.com/adobe/brackets/downloads)--make sure you download one
@@ -74,9 +76,9 @@ Brackets bugs are tracked in [the Brackets github issue tracker](https://github.
7476
When filing a new bug, please remember to include:
7577

7678
* Brackets version/sprint number (or commit SHA if you're pulling directly from the repo)
77-
* platform/OS version
78-
* repro steps, actual and expected results
79-
* link to test files (you can create a gist on [gist.github.com](https://gist.github.com/)
79+
* Platform/OS version
80+
* Steps to reproduce problem with actual and expected results
81+
* Link to test files (you can create a gist on [gist.github.com](https://gist.github.com/)
8082
if that's convenient)
8183

8284
More details on how to file an issue can be found [here](https://github.com/adobe/brackets/wiki/How-to-Report-an-Issue).

samples/es/Primeros Pasos/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ <h3>Visualiza cambios CSS en vivo en el navegador</h3>
9191
</samp>
9292

9393
<p class="note">
94-
Actualmente, Brackets sólo soporta Desarrollo en Vivo para CSS. Añadiremos soporte para Desarrollo en
95-
Vivo de HTML y JavaScript en próximas versionas. Las actualizaciones automáticas sólo son posibles en
96-
Google Chrome en estos momentos. Queremos trasladar esta funcionalidad a todos los grandes navegadores,
97-
y estamos deseando poder trabajar con ellos para conseguirlo.
94+
Actualmente, Brackets sólo soporta Desarrollo en Vivo para CSS. En estos momentos estamos trabajando en
95+
añadir soporte para Desarrollo en Vivo de HTML y JavaScript. En la versión actual, no podrás ver tus cambios
96+
en HTML hasta que guardes el archivo. Las actualizaciones automáticas sólo son posibles en Google Chrome en
97+
estos momentos. Queremos trasladar esta funcionalidad a todos los grandes navegadores, y estamos deseando
98+
poder trabajar con ellos para conseguirlo.
9899
</p>
99100

100101
<!--

samples/root/Getting Started/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ <h3>Preview CSS changes live in the browser</h3>
8888
</samp>
8989

9090
<p class="note">
91-
Today, Brackets only supports Live Preview for CSS. We will be adding Live Preview support for HTML
92-
and JavaScript support in a future release. Live previews are only possible with Google Chrome today.
93-
We want to bring this functionality to all major browsers, and we're looking forward to working with
94-
those vendors.
91+
Today, Brackets only supports Live Preview for CSS. We are currently working on Live Preview support
92+
for HTML and JavaScript. In the current version, you won't see changes to your HTML file until you save
93+
the document. Live previews are only possible with Google Chrome. We want to bring this functionality
94+
to all major browsers, and we're looking forward to working with those vendors.
9595
</p>
9696

9797
<!--

src/LiveDevelopment/Agents/RemoteFunctions.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function RemoteFunctions(experimental) {
192192
this.color = color;
193193
this.trigger = !!trigger;
194194
this.elements = [];
195-
this.orgColors = [];
195+
this.selector = "";
196196
}
197197

198198
Highlight.prototype = {
@@ -216,27 +216,30 @@ function RemoteFunctions(experimental) {
216216
var stylesToSet = {
217217
"left": _screenOffset(element, "offsetLeft") + "px",
218218
"top": _screenOffset(element, "offsetTop") + "px",
219-
"width": elementBounds.width + "px",
220-
"height": elementBounds.height + "px",
219+
"width": (elementBounds.width - 2) + "px",
220+
"height": (elementBounds.height - 2) + "px",
221221
"z-index": 2000000,
222222
"position": "absolute",
223223
"pointer-events": "none",
224224
"border-top-left-radius": styles.borderTopLeftRadius,
225225
"border-top-right-radius": styles.borderTopRightRadius,
226226
"border-bottom-left-radius": styles.borderBottomLeftRadius,
227-
"border-bottom-right-radius": styles.borderBottomRightRadius
227+
"border-bottom-right-radius": styles.borderBottomRightRadius,
228+
"border-style": "solid",
229+
"border-width": "1px",
230+
"border-color": "rgb(94,167,255)"
228231
};
229232

230233
var animateStartValues = {
231234
"opacity": 0,
232235
"background": "rgba(94,167,255, 0.5)",
233-
"box-shadow": "0 0 2px 1px rgba(94,167,255, 1), inset 0 0 4px 1px rgba(255,255,255,1)"
236+
"box-shadow": "0 0 6px 1px rgba(94,167,255, 0.6), inset 0 0 4px 1px rgba(255,255,255,1)"
234237
};
235238

236239
var animateEndValues = {
237240
"opacity": 1,
238241
"background": "rgba(94,167,255, 0.1)",
239-
"box-shadow": "0 0 1px 1px rgba(94,167,255, 0.6), inset 0 0 4px 1px rgba(255,255,255,0.8)"
242+
"box-shadow": "0 0 1px 0 rgba(94,167,255, 0), inset 0 0 4px 1px rgba(255,255,255,0.8)"
240243
};
241244

242245
var transitionValues = {
@@ -296,10 +299,18 @@ function RemoteFunctions(experimental) {
296299
},
297300

298301
redraw: function () {
299-
var i, highlighted = this.elements.slice(0);
302+
var i, highlighted;
303+
304+
// When redrawing a selector-based highlight, run a new selector
305+
// query to ensure we have the latest set of elements to highlight.
306+
if (this.selector) {
307+
highlighted = window.document.querySelectorAll(this.selector);
308+
} else {
309+
highlighted = this.elements.slice(0);
310+
}
300311

301312
this.clear();
302-
for (i in highlighted) {
313+
for (i = 0; i < highlighted.length; i++) {
303314
this.add(highlighted[i], false);
304315
}
305316
}
@@ -423,6 +434,7 @@ function RemoteFunctions(experimental) {
423434
for (i = 0; i < nodes.length; i++) {
424435
highlight(nodes[i]);
425436
}
437+
_remoteHighlight.selector = rule;
426438
}
427439

428440
// redraw active highlights

src/LiveDevelopment/Documents/CSSDocument.js

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ define(function CSSDocumentModule(require, exports, module) {
4949
"use strict";
5050

5151
var CSSAgent = require("LiveDevelopment/Agents/CSSAgent"),
52+
CSSUtils = require("language/CSSUtils"),
5253
EditorManager = require("editor/EditorManager"),
5354
HighlightAgent = require("LiveDevelopment/Agents/HighlightAgent"),
5455
Inspector = require("LiveDevelopment/Inspector/Inspector");
@@ -78,7 +79,6 @@ define(function CSSDocumentModule(require, exports, module) {
7879
if (doc.isDirty) {
7980
CSSAgent.reloadCSSForDocument(this.doc);
8081
}
81-
this.reloadRules();
8282

8383
this.onActiveEditorChange = this.onActiveEditorChange.bind(this);
8484
$(EditorManager).on("activeEditorChange", this.onActiveEditorChange);
@@ -146,45 +146,13 @@ define(function CSSDocumentModule(require, exports, module) {
146146
this.editor = null;
147147
}
148148
};
149-
150-
// Reload rules
151-
CSSDocument.prototype.reloadRules = function () {
152-
this.loadRulePromise = this.getStyleSheetFromBrowser().done(function (styleSheet) {
153-
this.rules = styleSheet.rules;
154-
this.loadRulePromise = null;
155-
if (this.pendingCursorActivity) {
156-
this.pendingCursorActivity = false;
157-
this.onCursorActivity();
158-
}
159-
}.bind(this));
160-
};
161-
162-
// find a rule in the given rules
163-
CSSDocument.prototype.ruleAtLocation = function ruleAtLocation(location) {
164-
var i, rule;
165-
for (i in this.rules) {
166-
rule = this.rules[i];
167-
if (rule.selectorRange.start <= location && location <= rule.style.range.end) {
168-
return rule;
169-
}
170-
}
171-
return null;
172-
};
173149

174150
CSSDocument.prototype.updateHighlight = function () {
175-
if (Inspector.config.highlight) {
176-
// If there is an active loadRulePromise, we can't accurately get the rule
177-
// at the location. Set a flag here so we can get called again once the
178-
// rules have arrived.
179-
if (this.loadRulePromise) {
180-
this.pendingCursorActivity = true;
181-
return;
182-
}
151+
if (Inspector.config.highlight && this.editor) {
183152
var codeMirror = this.editor._codeMirror;
184-
var location = codeMirror.indexFromPos(codeMirror.getCursor());
185-
var rule = this.ruleAtLocation(location);
186-
if (rule) {
187-
HighlightAgent.rule(rule.selectorText);
153+
var selector = CSSUtils.findSelectorAtDocumentPos(this.editor, codeMirror.getCursor());
154+
if (selector) {
155+
HighlightAgent.rule(selector);
188156
} else {
189157
HighlightAgent.hide();
190158
}
@@ -202,7 +170,6 @@ define(function CSSDocumentModule(require, exports, module) {
202170
CSSDocument.prototype.onChange = function onChange(event, editor, change) {
203171
// brute force: update the CSS
204172
CSSAgent.reloadCSSForDocument(this.doc);
205-
this.reloadRules();
206173
if (Inspector.config.highlight) {
207174
HighlightAgent.redraw();
208175
}

src/LiveDevelopment/LiveDevelopment.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
25-
/*global define, $, FileError, brackets, window */
25+
/*global define, $, brackets, window */
2626

2727
/**
2828
* LiveDevelopment manages the Inspector, all Agents, and the active LiveDocument
@@ -68,6 +68,7 @@ define(function LiveDevelopment(require, exports, module) {
6868
DocumentManager = require("document/DocumentManager"),
6969
EditorManager = require("editor/EditorManager"),
7070
FileUtils = require("file/FileUtils"),
71+
NativeFileError = require("file/NativeFileError"),
7172
NativeApp = require("utils/NativeApp"),
7273
PreferencesDialogs = require("preferences/PreferencesDialogs"),
7374
ProjectManager = require("project/ProjectManager"),
@@ -548,7 +549,7 @@ define(function LiveDevelopment(require, exports, module) {
548549
retryCount++;
549550

550551
if (!browserStarted && exports.status !== STATUS_ERROR) {
551-
url = launcherUrl + '?' + encodeURIComponent(url);
552+
url = launcherUrl + "?" + encodeURIComponent(url);
552553

553554
// If err === FileError.ERR_NOT_FOUND, it means a remote debugger connection
554555
// is available, but the requested URL is not loaded in the browser. In that
@@ -558,7 +559,7 @@ define(function LiveDevelopment(require, exports, module) {
558559
// --remote-debugging-port flag set.
559560
NativeApp.openLiveBrowser(
560561
url,
561-
err !== FileError.ERR_NOT_FOUND
562+
err !== NativeFileError.ERR_NOT_FOUND
562563
)
563564
.done(function () {
564565
browserStarted = true;
@@ -567,7 +568,7 @@ define(function LiveDevelopment(require, exports, module) {
567568
var message;
568569

569570
_setStatus(STATUS_ERROR);
570-
if (err === FileError.NOT_FOUND_ERR) {
571+
if (err === NativeFileError.NOT_FOUND_ERR) {
571572
message = Strings.ERROR_CANT_FIND_CHROME;
572573
} else {
573574
message = StringUtils.format(Strings.ERROR_LAUNCHING_BROWSER, err);
@@ -623,6 +624,13 @@ define(function LiveDevelopment(require, exports, module) {
623624
agents.highlight.hide();
624625
}
625626
}
627+
628+
/** Redraw highlights **/
629+
function redrawHighlight() {
630+
if (Inspector.connected() && agents.highlight) {
631+
agents.highlight.redraw();
632+
}
633+
}
626634

627635
/** Triggered by a document change from the DocumentManager */
628636
function _onDocumentChange() {
@@ -697,5 +705,6 @@ define(function LiveDevelopment(require, exports, module) {
697705
exports.getLiveDocForPath = getLiveDocForPath;
698706
exports.showHighlight = showHighlight;
699707
exports.hideHighlight = hideHighlight;
708+
exports.redrawHighlight = redrawHighlight;
700709
exports.init = init;
701710
});

src/LiveDevelopment/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ define(function main(require, exports, module) {
211211
}
212212
});
213213
}
214+
215+
// Redraw highlights when window gets focus. This ensures that the highlights
216+
// will be in sync with any DOM changes that may have occurred.
217+
$(window).focus(function () {
218+
if (Inspector.connected() && config.highlight) {
219+
LiveDevelopment.redrawHighlight();
220+
}
221+
});
214222
}
215223

216224
// init prefs

0 commit comments

Comments
 (0)