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

Commit 730a2dc

Browse files
committed
Merge remote-tracking branch 'origin/master' into randy/display-inline-editor-errors
2 parents 8595246 + 858d146 commit 730a2dc

9 files changed

Lines changed: 622 additions & 27 deletions

File tree

src/filesystem/FileSystem.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,9 @@ define(function (require, exports, module) {
350350
// entries always return cached data if it exists!
351351
this._index.visitAll(function (child) {
352352
if (child.fullPath.indexOf(entry.fullPath) === 0) {
353-
child._clearCachedData();
353+
// 'true' so entry doesn't try to clear its immediate childrens' caches too. That would be redundant
354+
// with the visitAll() here, and could be slow if we've already cleared its parent (#7150).
355+
child._clearCachedData(true);
354356
}
355357
}.bind(this));
356358

@@ -718,7 +720,8 @@ define(function (require, exports, module) {
718720
if (!watchedRoot || !watchedRoot.filter(directory.name, directory.parentPath)) {
719721
this._index.visitAll(function (entry) {
720722
if (entry.fullPath.indexOf(directory.fullPath) === 0) {
721-
entry._clearCachedData();
723+
// Passing 'true' for a similar reason as in _unwatchEntry() - see #7150
724+
entry._clearCachedData(true);
722725
}
723726
}.bind(this));
724727

@@ -773,7 +776,8 @@ define(function (require, exports, module) {
773776
if (!path) {
774777
// This is a "wholesale" change event; clear all caches
775778
this._index.visitAll(function (entry) {
776-
entry._clearCachedData();
779+
// Passing 'true' for a similar reason as in _unwatchEntry() - see #7150
780+
entry._clearCachedData(true);
777781
});
778782

779783
this._fireChangeEvent(null);

src/nls/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
1. Create a subfolder of the `nls` folder whose name is the language or locale you want to
44
create a translation for.
5-
* If you're creating a general translation for a language, just use its two-letter code
5+
* If you're creating a general translation for a language, just use its two-letter code
66
(e.g. `en`, `de`).
7-
* If you're creating a locale-specific translation for a particular country, add a hyphen
7+
* If you're creating a locale-specific translation for a particular country, add a hyphen
88
and the country code in lowercase (e.g. `en-ca`, `en-gb`).
99
2. Add an entry for your translation to the `module.exports` object in `nls/strings.js`.
1010
3. Edit the root `strings-app.js` file and add a new `LOCALE_`* entry for your language, as seen in
@@ -22,7 +22,7 @@ Localization is provided via the [require.js i18n plugin](http://requirejs.org/d
2222
### Translating the Getting Started project
2323

2424
When first installed, Brackets will open a Getting Started project that serves
25-
as an introduction to Brackets features. This project can be translated by
25+
as an introduction to Brackets features. This project can be translated by
2626
providing a ``urls.js`` file that points to a localized directory under the
2727
``samples`` folder at the root of the Brackets repository. See the French
2828
localization (`src/nls/fr/urls.js`) for an example.
@@ -71,6 +71,7 @@ The following languages have been contributed by the Brackets community:
7171
* Swedish (sv)
7272
* Turkish (tr)
7373
* Simplified Chinese (zh-cn)
74+
* Indonesia (id)
7475

7576
These translations _can be directly modified_ through our normal pull request
7677
process.

src/nls/id/strings.js

Lines changed: 497 additions & 0 deletions
Large diffs are not rendered by default.

src/nls/id/urls.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2014 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+
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
25+
/*global define */
26+
27+
define({
28+
// Relative to the samples folder
29+
"GETTING_STARTED" : "id/Memulai",
30+
"WEB_PLATFORM_DOCS_LICENSE" : "http://creativecommons.org/licenses/by/3.0/deed.id"
31+
});

src/nls/root/strings-app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ define({
3636
"LOCALE_ES" : "Español",
3737
"LOCALE_FI" : "suomi",
3838
"LOCALE_FR" : "Français",
39+
"LOCALE_ID" : "Indonesia",
3940
"LOCALE_IT" : "italiano",
4041
"LOCALE_JA" : "日本語",
4142
"LOCALE_NB" : "norsk",
@@ -52,5 +53,5 @@ define({
5253
"LOCALE_TR" : "Türkçe",
5354
"LOCALE_ZH_CN" : "简体中文",
5455
"LOCALE_HU" : "Magyar",
55-
"LOCALE_KO" : "한국어",
56+
"LOCALE_KO" : "한국어"
5657
});

src/nls/strings.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
/*
22
* Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
3-
*
3+
*
44
* 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
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
99
* Software is furnished to do so, subject to the following conditions:
10-
*
10+
*
1111
* The above copyright notice and this permission notice shall be included in
1212
* all copies or substantial portions of the Software.
13-
*
13+
*
1414
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1616
* 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
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
2020
* DEALINGS IN THE SOFTWARE.
21-
*
21+
*
2222
*/
2323

2424
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
2525
/*global define */
2626

2727
define(function (require, exports, module) {
28-
28+
2929
"use strict";
30-
30+
3131
// Code that needs to display user strings should call require("strings") to load
3232
// src/strings.js. This file will dynamically load strings.js for the specified brackets.locale.
3333
//
@@ -41,10 +41,11 @@ define(function (require, exports, module) {
4141
"de": true,
4242
"el": true,
4343
"es": true,
44-
"fa-ir": true,
44+
"fa-ir": true,
4545
"fi": true,
4646
"fr": true,
4747
"hu": true,
48+
"id": true,
4849
"it": true,
4950
"ja": true,
5051
"ko": true,

src/nls/urls.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ define(function (require, exports, module) {
4040
"fa-ir": true,
4141
"fi": true,
4242
"fr": true,
43+
"id": true,
4344
"it": true,
4445
"ja": true,
4546
"ko": true,

test/spec/FileSystem-test.js

Lines changed: 63 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, maxerr: 50 */
25-
/*global define, describe, it, expect, beforeEach, afterEach, waits, waitsFor, runs, $, window, jasmine */
25+
/*global define, describe, it, expect, beforeEach, afterEach, waits, waitsFor, waitsForDone, runs, $, window, jasmine, spyOn */
2626

2727
define(function (require, exports, module) {
2828
"use strict";
@@ -32,7 +32,8 @@ define(function (require, exports, module) {
3232
FileSystem = require("filesystem/FileSystem"),
3333
FileSystemStats = require("filesystem/FileSystemStats"),
3434
FileSystemError = require("filesystem/FileSystemError"),
35-
MockFileSystemImpl = require("./MockFileSystemImpl");
35+
MockFileSystemImpl = require("./MockFileSystemImpl"),
36+
Async = require("utils/Async");
3637

3738

3839
describe("FileSystem", function () {
@@ -1342,13 +1343,70 @@ define(function (require, exports, module) {
13421343
});
13431344
});
13441345

1345-
it("should invalidate cached data after unwatch", function () {
1346+
it("should recursively invalidate cached data after unwatch", function () {
1347+
var file1 = fileSystem.getFileForPath("/file1.txt"),
1348+
subdir = fileSystem.getDirectoryForPath("/subdir"),
1349+
file4 = fileSystem.getFileForPath("/subdir/file4.txt"),
1350+
childSubdir = fileSystem.getDirectoryForPath("/subdir/child"),
1351+
file5 = fileSystem.getFileForPath("/subdir/child/file5.txt"),
1352+
entries = [file1, subdir, file4, childSubdir, file5],
1353+
unwatchCb = errorCallback();
1354+
1355+
runs(function () {
1356+
var readAllPromise = Async.doInParallel(entries, function (entry) {
1357+
// Confirm watched and no cached data yet
1358+
expect(entry._isWatched()).toBe(true);
1359+
expect(entry._contents).toBeFalsy();
1360+
1361+
// Read contents
1362+
var result = new $.Deferred(),
1363+
cb = function (err, contents) {
1364+
expect(err).toBeFalsy();
1365+
result.resolve();
1366+
};
1367+
if (entry.isFile) {
1368+
entry.read(cb);
1369+
} else {
1370+
entry.getContents(cb);
1371+
}
1372+
return result;
1373+
});
1374+
1375+
waitsForDone(readAllPromise);
1376+
});
1377+
runs(function () {
1378+
// Confirm all entries now have cached data
1379+
entries.forEach(function (entry) {
1380+
expect(entry._contents).toBeTruthy();
1381+
});
1382+
1383+
// Unwatch and count how many visitAll() calls it took
1384+
spyOn(fileSystem._index, "visitAll").andCallThrough();
1385+
1386+
fileSystem.unwatch(fileSystem.getDirectoryForPath("/"), unwatchCb);
1387+
});
1388+
waitsFor(function () { return unwatchCb.wasCalled; });
1389+
1390+
runs(function () {
1391+
// Confirm visitAll() didn't traverse the whole index multiple times (#7150).
1392+
// One call expected for _unwatchEntry() calling _clearCachedData(), one for unwatch() calling removeEntry().
1393+
expect(fileSystem._index.visitAll.callCount).toBe(2);
1394+
1395+
// Confirm all entries have become uncached
1396+
entries.forEach(function (entry) {
1397+
expect(entry._isWatched()).toBe(false);
1398+
expect(entry._contents).toBeFalsy();
1399+
});
1400+
});
1401+
});
1402+
1403+
it("should invalidate cached data after unwatch, but allow read again", function () {
13461404
var file,
13471405
cb0 = readCallback(),
13481406
cb1 = errorCallback(),
13491407
cb2 = readCallback(),
13501408
savedHash;
1351-
1409+
13521410
// confirm watched and empty cached data
13531411
runs(function () {
13541412
file = fileSystem.getFileForPath(filename);
@@ -1387,6 +1445,7 @@ define(function (require, exports, module) {
13871445
expect(cb2.error).toBeFalsy();
13881446
expect(cb2.data).toBe(cb0.data);
13891447
expect(file._isWatched()).toBe(false);
1448+
expect(file._contents).toBeFalsy();
13901449
expect(file._hash).toBeTruthy();
13911450
expect(readCalls).toBe(2);
13921451
});

test/spec/MockFileSystemImpl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ define(function (require, exports, module) {
162162
if (options.expectedContents !== _model.readFile(path)) {
163163
cb(FileSystemError.CONTENTS_MODIFIED);
164164
return;
165-
}
165+
}
166166
} else {
167167
cb(FileSystemError.CONTENTS_MODIFIED);
168168
return;

0 commit comments

Comments
 (0)