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

New FileSystem API #5797

Merged
merged 206 commits into from
Nov 8, 2013
Merged
Show file tree
Hide file tree
Changes from 205 commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
f73b6ed
Start sketching out FileSystem
gruehle Jun 18, 2013
26c31d3
Add FileIndex
gruehle Jun 20, 2013
4a4471c
Move files to new filesystem folder
gruehle Jun 20, 2013
619dd45
Add FileSystemEntry, File, and Directory classes.
gruehle Jun 20, 2013
714732b
Get basic file reading and writing working
gruehle Jun 24, 2013
1fa9144
Add Directory implementation. Make more stuff work.
gruehle Jun 25, 2013
cb6b986
Set indexing when root path is set.
gruehle Jun 28, 2013
5fcf425
Cache file contents. Hook up Find in Files.
gruehle Jun 28, 2013
bf68b86
Add file open dialogs and hook them up.
gruehle Jun 29, 2013
868e45b
Migrate brackets.js from NativeFileSystem to FileSystem
gruehle Jun 29, 2013
13368c4
Reorganize impl files
gruehle Jul 2, 2013
8a56cee
Getting started with directory watchers.
gruehle Jul 4, 2013
045f346
Initial integration into core.
gruehle Jul 8, 2013
6be82be
Dropbox hack for demo purposes...
gruehle Jul 8, 2013
89d1dbc
Back to 100 find in files results.
gruehle Jul 8, 2013
543e122
Delete file/folder from project tree.
gruehle Jul 11, 2013
0089986
Add impl registration. Fix some JSDoc comments.
gruehle Jul 12, 2013
848e0b6
Make FileSystem a class, and support multiple instances.
gruehle Jul 21, 2013
819a208
Use fullPath and name getters instead of getPath() and getName().
gruehle Jul 23, 2013
65f69aa
Merge with master
gruehle Aug 14, 2013
ba93b48
More cleanup after merge with master
gruehle Aug 14, 2013
45899bb
Start getting unit tests to run
gruehle Aug 14, 2013
c89ae3f
Unit tests
gruehle Aug 16, 2013
ce74bc8
Cleanup
gruehle Aug 16, 2013
eaca879
Minor cleanup
gruehle Sep 11, 2013
ada68e2
Merge with master
gruehle Sep 11, 2013
490ce52
Fix a bunch of unit test failures.
gruehle Sep 11, 2013
1cacf78
Submodule updates
gruehle Sep 11, 2013
1c1fb62
Fix CSSCodeHints unit tests
gruehle Sep 12, 2013
3cdcfb4
Remember file system name in recent projects dropdown.
gruehle Sep 13, 2013
6a9b2d0
Do not stat an untitled document's underlying file
Sep 13, 2013
0d2b8d5
Merge branch 'brackets' into glenn/file-system
Sep 13, 2013
d5f3259
ProjectManager.renameItem work-in-progress
Sep 14, 2013
599755c
Add a question comment so I don't forget about it
Sep 14, 2013
b252859
Add another question
Sep 16, 2013
b124d1b
Merge branch 'brackets' into glenn/file-system
Sep 16, 2013
d93a85e
Revert comments for cleanliness in the public branch
Sep 16, 2013
5237004
Fix a watcherCallback bug
Sep 16, 2013
4d362dd
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Sep 17, 2013
3035dca
fix the isDirectory test in handleFileDelete
Sep 18, 2013
6df65b9
Remove a vestigial variable in renameItem
Sep 18, 2013
b5248bf
For consistency, replace a self variable in favor of .bind(this)
Sep 18, 2013
daec4a2
Put properties on prototype instead of instance.
gruehle Sep 19, 2013
b10bb35
Silently ignore directory entries without stats.
Sep 23, 2013
2640846
Merge branch 'brackets' into glenn/file-system
Sep 23, 2013
e0e4f4d
Yes, FileIndex.getAllFiles really should always return a copy of the …
Sep 23, 2013
da95b3a
Merge branch 'brackets' into glenn/file-system
Sep 24, 2013
e8be7c0
Merge branch 'brackets' into glenn/file-system
Oct 1, 2013
b08d0d1
Change FileSystemManager.createFileSystem() to be async -- allowing
peterflynn Oct 3, 2013
f451101
Merge branch 'master' into glenn/file-system
gruehle Oct 4, 2013
5352487
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 4, 2013
b1ad00c
Convert file system to use callbacks instead of promises.
gruehle Oct 5, 2013
8705bbb
Fix new file (in project).
gruehle Oct 7, 2013
29ad888
Add error codes.
gruehle Oct 8, 2013
a3b5e70
Make 'find in files' search unsaved contents.
gruehle Oct 8, 2013
88283d9
Error name cleanup. FileSyncManager cleanup.
gruehle Oct 8, 2013
9ffe75f
Fix file watching
gruehle Oct 8, 2013
996ea0d
Remove FileSystem.pathExists(). Fix a bunch of unit test failures.
gruehle Oct 8, 2013
d0cb127
Use DocumentManager.getDocumentForPath() for find in files. Commented…
gruehle Oct 9, 2013
fb2c451
Update DragAndDrop for new file system.
gruehle Oct 9, 2013
8269ff1
Move FileSystem.getDirectoryContents to Directory.getContents
Oct 9, 2013
af57cff
Standardize back on trailing-/ for directory paths. This is safer for…
peterflynn Oct 11, 2013
087a451
Cleaner fix for race condition bugs in JS code hints unit tests.
peterflynn Oct 11, 2013
9dc6a18
First pass at adding rename functionality. Still some loose ends to c…
gruehle Oct 11, 2013
5d8394d
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 11, 2013
c5d15eb
Move InMemoryFile out of filesystem. It is now a Brackets-specific de…
peterflynn Oct 11, 2013
c5bafcf
Fixups for ending '/' in directory paths.
gruehle Oct 11, 2013
af80be7
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 11, 2013
6f01dfe
Fix JSLint error.
gruehle Oct 11, 2013
333bb13
Use non-persistent file watchers.
gruehle Oct 11, 2013
8050678
Properly handle empty directories.
gruehle Oct 12, 2013
89945f8
Add ProjectManager.getAllFiles(), replacing FileSystem.getFileList().…
gruehle Oct 13, 2013
266cdaa
Add FileSystem.watch and FileSystem.unwatch; remove FileSystem._scanD…
Oct 14, 2013
b060e8f
Serialize watch/unwatch requests
Oct 14, 2013
94f3f4d
Do not unwatch after a failed watch attempt
Oct 15, 2013
444fbb0
* Normalize out ".."s in paths
peterflynn Oct 15, 2013
93a276c
Recursive visit calls should use newOptions instead of options.
iwehrman Oct 15, 2013
53992af
Do not create multiple FSWatchers for the same path
Oct 15, 2013
a91c32c
Unbreak ProjectManager.getAllFiles()
iwehrman Oct 16, 2013
ca5820f
TODO cleanups
gruehle Oct 16, 2013
1d815b9
Fix *file* watching on Windows: normalize out doubled "/"es in paths
peterflynn Oct 16, 2013
f5e8269
Ensure the callbacks for write operations (including their index fixups)
peterflynn Oct 16, 2013
466e044
Make FileIndex.removeEntry a no-op for now.
iwehrman Oct 16, 2013
1c8f5a1
Explicitly watch and unwatch directories in breadth-first order
Oct 17, 2013
d091932
Remove superfluous warning message
Oct 17, 2013
634ab02
Fix non-absolute path assertions while running unit tests
peterflynn Oct 17, 2013
9576a8c
Merge remote-tracking branch 'origin/glenn/file-system' into glenn/fi…
peterflynn Oct 17, 2013
413fe4f
Move shouldShow() back onto ProjectManager, and pass it into FileSyst…
peterflynn Oct 17, 2013
290da88
Make FileSystem a singleton.
gruehle Oct 17, 2013
a29d37b
Merge
gruehle Oct 17, 2013
931e8d3
FileSystem singleton cleanup. Clear cached data on file system change…
gruehle Oct 18, 2013
e142295
Bump Tern submodule to include a patch for crashing bug caused by the…
Oct 18, 2013
fa0171d
Catch and handle file watcher errors
Oct 18, 2013
eff3422
Add FileSystemEntry.chmod
Oct 21, 2013
00b315a
Convert SpecRunnerUtils.chmod and SpecRunnerUtils._stat to use FileSy…
Oct 21, 2013
bfb113d
Merge branch 'brackets' into glenn/file-system
Oct 21, 2013
387eb81
Temporarily disable caching and file watchers. They will return.
gruehle Oct 21, 2013
bd967ff
Fix failing DocumentCommandHandlers tests
Oct 21, 2013
26c792c
Merge remote-tracking branch 'github/glenn/file-system' into glenn/fi…
Oct 21, 2013
4ab1a60
Rename filesystem/Error -> filesystem/FileSystemError
Oct 21, 2013
0d32066
Fix submodule SHAs
Oct 22, 2013
5e7bd59
Fix rename
gruehle Oct 22, 2013
cee12e8
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 22, 2013
9f2578d
Remove 'projectFilesChange' event.
gruehle Oct 22, 2013
80fa112
Use FileSystemError codes for openLiveBrowser/closeLiveBrowser
gruehle Oct 22, 2013
3ad103c
More efficient way to read text for bulk operations like Find in Files:
peterflynn Oct 22, 2013
8403184
Remove FileSystemEntry objects from the FileIndex upon unwatch, unlin…
Oct 22, 2013
892a808
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
Oct 22, 2013
202da51
Restore projectRefresh event
Oct 22, 2013
3ba67f5
Remove change callback. Add on() and off() methods to FileSystem.
gruehle Oct 22, 2013
ec16c64
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 22, 2013
7756ce1
Re-enable LowLevelFile-IO, NativeFileSystem and FileIndexManager tests
Oct 23, 2013
654c984
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 23, 2013
e2a3a15
Fix error handling with rename and new file/folder
gruehle Oct 23, 2013
276c403
JSDoc additions and cleanup.
gruehle Oct 23, 2013
89cda23
Fix LanguageManager tests
Oct 23, 2013
8ae8dc5
Remove dependency on FileIndexManager
Oct 23, 2013
8fdc8d0
Reintroduce caching for directory contents: we can be less conservati…
peterflynn Oct 23, 2013
df26c44
Merge remote-tracking branch 'origin/glenn/file-system' into glenn/fi…
peterflynn Oct 23, 2013
98954da
Fix frequent project tree flickering & scroll pos loss: effectively r…
peterflynn Oct 23, 2013
fa70a26
Fix a ProjectManager test
Oct 23, 2013
181278c
Re-disable the FileIndexManager tests
Oct 23, 2013
e53bbfb
Re-enable some previously failing tests and expectations
Oct 24, 2013
955c6d3
Add more FileSystem unit tests. A new MockFileSystemImpl is used to m…
gruehle Oct 24, 2013
2ab57c0
Merge branch 'brackets' into glenn/file-system
Oct 24, 2013
63f452e
Fix the acorn SHA
Oct 24, 2013
d3e0b2d
Remove many instances of brackets.fs usage
Oct 24, 2013
35a6cc0
Remove unlink callback
Oct 24, 2013
8c60a81
Replace NativeFileSystem with FileSystem in ImageViewer
Oct 24, 2013
a88bbff
Making callbacks optional for mutating operations; cleanup JS doc a bit
Oct 24, 2013
af54c57
- Fix getAllFiles() to exclude isBinaryFile() matches just like old
peterflynn Oct 24, 2013
94a9cb8
MockFileSystemImpl additions: watch support, and a 'when' function fo…
gruehle Oct 24, 2013
e0ebe14
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 24, 2013
f8c86db
move FileSystemEntry.isFile() and isDirectory() to FileSystemEntry.is…
Oct 24, 2013
d6e2486
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
Oct 24, 2013
858e452
Fix regression in RecentProjects: current project was getting listed at
peterflynn Oct 25, 2013
ea9196d
Merge branch 'brackets' into glenn/file-system
Oct 25, 2013
8066e30
Make the default mode for mkdir 755 instead of 777.
iwehrman Oct 25, 2013
eb49314
Delete FileSystemImpl.js in favor of a wiki page: https://github.com/…
iwehrman Oct 25, 2013
ab3cb48
Code cleanups from reviewing the diffs.
gruehle Oct 25, 2013
b21ae30
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 25, 2013
354a838
Compatibility shims for frequently-used FileIndexManager & NativeFile…
peterflynn Oct 25, 2013
54527b6
Handle deleted files in FindInFiles.js
gruehle Oct 25, 2013
2ecc22f
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Oct 25, 2013
173442c
ProjectManager.shouldShow() takes a FileSystemEntry instead of a path.
gruehle Oct 25, 2013
67c19d0
Merge branch 'brackets' into glenn/file-system
Oct 26, 2013
400ed27
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
Oct 26, 2013
e9a5a6b
Merge branch 'brackets' into glenn/file-system
Oct 26, 2013
c5279bc
Precompute FileSystemEntry.name and only update it when FileSystemEnt…
Oct 26, 2013
dd69c94
Fix LowLevelFileIO tests by explicitly defining UTF8 and UTF16 encodings
Oct 28, 2013
980acaf
Merge branch 'brackets' into glenn/file-system
Oct 28, 2013
992bdaa
Unit tests for various file system race conditions, ensuring that cal…
peterflynn Oct 28, 2013
3e67b04
Add more FileSystem tests.
gruehle Oct 28, 2013
4a0929e
Remove FileIndexManager tests.
gruehle Oct 28, 2013
04e4c6c
Remove NativeFileSystem tests
gruehle Oct 28, 2013
70c9453
Merge with origin/master
gruehle Oct 28, 2013
ddb3500
Fix failing JSQuickEdit performance test.
gruehle Oct 29, 2013
84c0e1c
- Change ScopeManager to use getDocumentText() for efficiency
peterflynn Oct 29, 2013
d2723a4
Call back with an empty array of entries and stats (instead of undefi…
Oct 29, 2013
b2bd648
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
Oct 29, 2013
2362dd8
Just check the entry's name, not it's entire path, when testing for b…
Oct 30, 2013
b7a8372
Add a FindIn perf timer
Oct 30, 2013
4cddefc
Execute read and stat calls in parallel in AppshellFileSystem.readFil…
Oct 30, 2013
3eac55a
SpecRunnerUtils.chmod takes a string parameter, not a number.
Oct 30, 2013
ac5adc5
Don't try to get a file for an empty path.
Oct 31, 2013
0942969
Merge branch 'brackets' into glenn/file-system
Oct 31, 2013
e33f78b
Remove change/rename console.log statements
Oct 31, 2013
507a5c0
Remove an unused instance of NativeFileSystem
Oct 31, 2013
0cb5182
Dial back the unindexed entry warning a bit.
Oct 31, 2013
fa8c824
Fix two bugs in filesystem port of DocumentCommandHandlers:
peterflynn Nov 1, 2013
998f619
Fix & re-enable inline editor unit test on file-system branch -- ensure
peterflynn Nov 1, 2013
bc831b9
Respond to review comments.
gruehle Nov 1, 2013
f04b2d2
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Nov 1, 2013
c073637
Add FileSystemEntry.parentPath getter.
gruehle Nov 2, 2013
004ff69
Merge branch 'brackets' into glenn/file-system
Nov 2, 2013
79335bd
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
Nov 2, 2013
3dde788
Double quotes
gruehle Nov 2, 2013
34085c5
Implement the clarified spec of FileSystemImpl.readdir and Directory.…
Nov 4, 2013
2184802
Avoid duplicated implementations of filtering ProjectManager.getAllFi…
peterflynn Nov 4, 2013
779019d
Adjust the implementation of Directory.getContents to also return an …
Nov 4, 2013
13562ee
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
gruehle Nov 4, 2013
5967e2f
Replace references to FileEntry and DirectoryEntry with references to…
Nov 5, 2013
7561f75
Respond to review comments.
gruehle Nov 5, 2013
7c1a450
Fix merge conflict
gruehle Nov 5, 2013
ce60edc
Merge branch 'brackets' into glenn/file-system
Nov 5, 2013
92ea58b
Add FileSystemError.TOO_MANY_ENTRIES and a maxEntries option to FileS…
Nov 6, 2013
7bff28e
Show what used to be the FileIndexManager too-many-files error dialog…
Nov 6, 2013
cc52b50
Off-by-one error
Nov 6, 2013
af294e1
If the file is created during by a write, send a change notification …
Nov 6, 2013
d1b698c
Add tests for FileSystemEntry.visit
Nov 6, 2013
4d6c73d
Only mark one category of LanguageManager tests as integration tests …
Nov 7, 2013
0fd2e14
Respond to more review comments.
gruehle Nov 7, 2013
dffad5f
Merge
gruehle Nov 7, 2013
629bc8f
Fix the failFast callback err logic in FSE.visit
Nov 7, 2013
4d83481
Do not watch filtered directories
Nov 7, 2013
b34a1a3
Directory.getContents has four parameters, the last of which is stats…
Nov 7, 2013
1b626bd
Initialize _watchResults in the constructor
Nov 7, 2013
453f472
Wrap sensitive callbacks in a try-catch block
Nov 7, 2013
7b5042e
Unbreak FileSystem.init
Nov 7, 2013
d77cf16
More cleanup
gruehle Nov 7, 2013
7595fdc
Many miscellaneous fixes from Peter's and Glenn's reviews
Nov 7, 2013
3280c1d
Merge branch 'glenn/file-system' of https://github.com/adobe/brackets…
Nov 7, 2013
6cbe02c
Use FileSystem change/rename events instead of the old ProjectManager…
Nov 7, 2013
b5e5da5
Revert an unnecessary and inconsistent unit test change
Nov 7, 2013
609d873
Replace try-catch-finally callback blocks in the filesystem with try-…
Nov 7, 2013
60c8cd0
Reset default FSE.visit maxDepth to 100
Nov 8, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,14 @@ define(function LiveDevelopment(require, exports, module) {
var STATUS_SYNC_ERROR = exports.STATUS_SYNC_ERROR = 5;

var Async = require("utils/Async"),
FileIndexManager = require("project/FileIndexManager"),
Dialogs = require("widgets/Dialogs"),
DefaultDialogs = require("widgets/DefaultDialogs"),
DocumentManager = require("document/DocumentManager"),
EditorManager = require("editor/EditorManager"),
FileServer = require("LiveDevelopment/Servers/FileServer").FileServer,
FileSystemError = require("filesystem/FileSystemError"),
FileUtils = require("file/FileUtils"),
LiveDevServerManager = require("LiveDevelopment/LiveDevServerManager"),
NativeFileError = require("file/NativeFileError"),
NativeApp = require("utils/NativeApp"),
PreferencesDialogs = require("preferences/PreferencesDialogs"),
ProjectManager = require("project/ProjectManager"),
Expand Down Expand Up @@ -674,7 +673,7 @@ define(function LiveDevelopment(require, exports, module) {
var baseUrl = ProjectManager.getBaseUrl(),
hasOwnServerForLiveDevelopment = (baseUrl && baseUrl.length);

FileIndexManager.getFileInfoList("all").done(function (allFiles) {
ProjectManager.getAllFiles().done(function (allFiles) {
var projectRoot = ProjectManager.getProjectRoot().fullPath,
containingFolder,
indexFileFound = false,
Expand Down Expand Up @@ -1069,7 +1068,7 @@ define(function LiveDevelopment(require, exports, module) {
var message;

_setStatus(STATUS_ERROR);
if (err === NativeFileError.NOT_FOUND_ERR) {
if (err === FileSystemError.NOT_FOUND) {
message = Strings.ERROR_CANT_FIND_CHROME;
} else {
message = StringUtils.format(Strings.ERROR_LAUNCHING_BROWSER, err);
Expand Down
34 changes: 23 additions & 11 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ define(function (require, exports, module) {
CommandManager = require("command/CommandManager"),
CodeHintManager = require("editor/CodeHintManager"),
PerfUtils = require("utils/PerfUtils"),
FileIndexManager = require("project/FileIndexManager"),
FileSystem = require("filesystem/FileSystem"),
QuickOpen = require("search/QuickOpen"),
Menus = require("command/Menus"),
FileUtils = require("file/FileUtils"),
Expand All @@ -89,7 +89,6 @@ define(function (require, exports, module) {
Async = require("utils/Async"),
UpdateNotification = require("utils/UpdateNotification"),
UrlParams = require("utils/UrlParams").UrlParams,
NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem,
PreferencesManager = require("preferences/PreferencesManager"),
Resizer = require("utils/Resizer"),
LiveDevelopmentMain = require("LiveDevelopment/main"),
Expand All @@ -114,8 +113,17 @@ define(function (require, exports, module) {
require("extensibility/InstallExtensionDialog");
require("extensibility/ExtensionManagerDialog");

// Compatibility shims for filesystem API migration
require("project/FileIndexManager");
require("file/NativeFileSystem");
require("file/NativeFileError");

PerfUtils.addMeasurement("brackets module dependencies resolved");


// Initialize the file system
FileSystem.init(require("filesystem/impls/appshell/AppshellFileSystem"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to understand what you had in mind: I guess file system should be loaded before the global object is constructed, so that it would make decisions based on whether FileSystem has been initialized instead of presence of brackets.fs. Perhaps, Global.js should expose an explicit init() which could be called from within bracket.js instead of initializing on module load as it is done now. Is it something along the lines of your thinking?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will always be some filesystem (else Brackets will be 100% broken), so nothing useful that Globals could determine by looking at that alone. The inBrowser flag shouldn't really be about what type of filesystem impl you're using anyway -- see my response in the forum thread for my thoughts there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @peterflynn mentioned, the inBrowser check and file system initialization are separate items.

However, we should not be hard-coding the file system impl/init() in this file. At minimum, this should be factored into a separate file. It would be nice if the impl could be declared in a config file (along with other inBrowser-related features). I filed #5869 for tracking.


// Local variables
var params = new UrlParams();

Expand All @@ -141,7 +149,7 @@ define(function (require, exports, module) {
JSUtils : JSUtils,
CommandManager : CommandManager,
FileSyncManager : FileSyncManager,
FileIndexManager : FileIndexManager,
FileSystem : FileSystem,
Menus : Menus,
KeyBindingManager : KeyBindingManager,
CodeHintManager : CodeHintManager,
Expand All @@ -162,6 +170,7 @@ define(function (require, exports, module) {
RemoteAgent : require("LiveDevelopment/Agents/RemoteAgent"),
HTMLInstrumentation : require("language/HTMLInstrumentation"),
MultiRangeInlineEditor : require("editor/MultiRangeInlineEditor").MultiRangeInlineEditor,
LanguageManager : LanguageManager,
doneLoading : false
};

Expand All @@ -172,7 +181,7 @@ define(function (require, exports, module) {

function _onReady() {
PerfUtils.addMeasurement("window.document Ready");

EditorManager.setEditorHolder($("#editor-holder"));

// Let the user know Brackets doesn't run in a web browser yet
Expand Down Expand Up @@ -223,12 +232,14 @@ define(function (require, exports, module) {
if (!params.get("skipSampleProjectLoad") && !prefs.getValue("afterFirstLaunch")) {
prefs.setValue("afterFirstLaunch", "true");
if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) {
var dirEntry = new NativeFileSystem.DirectoryEntry(initialProjectPath);

dirEntry.getFile("index.html", {}, function (fileEntry) {
var promise = CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: fileEntry.fullPath });
promise.then(deferred.resolve, deferred.reject);
}, deferred.reject);
FileSystem.resolve(initialProjectPath + "index.html", function (err, file) {
if (!err) {
var promise = CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: file.fullPath });
promise.then(deferred.resolve, deferred.reject);
} else {
deferred.reject();
}
});
} else {
deferred.resolve();
}
Expand Down Expand Up @@ -333,8 +344,9 @@ define(function (require, exports, module) {

// TODO: (issue 269) to support IE, need to listen to document instead (and even then it may not work when focus is in an input field?)
$(window).focus(function () {
// This call to syncOpenDocuments() *should* be a no-op now that we have
// file watchers, but is still here as a safety net.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is a bit ahead of itself since we haven't yet added file watchers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider it a tease, or optimism, or both...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we could actually remove this whole listener now, though -- the wholesale FileSystem "change" event sent on window focus covers this 100% already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we think we'd want this back (explicitly check 'important' files) when watchers are reintroduced and the fake change event gets turned off...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this should be kept in as a "safety net" in case watchers get unreliable. It may be redundant, but seems worth it for the extra safety.

FileSyncManager.syncOpenDocuments();
FileIndexManager.markDirty();
});

// Prevent unhandled middle button clicks from triggering native behavior
Expand Down
35 changes: 19 additions & 16 deletions src/document/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
define(function (require, exports, module) {
"use strict";

var NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem,
EditorManager = require("editor/EditorManager"),
var EditorManager = require("editor/EditorManager"),
FileUtils = require("file/FileUtils"),
InMemoryFile = require("document/InMemoryFile"),
PerfUtils = require("utils/PerfUtils"),
LanguageManager = require("language/LanguageManager");

Expand Down Expand Up @@ -69,7 +69,7 @@ define(function (require, exports, module) {
* deleted -- When the file for this document has been deleted. All views onto the document should
* be closed. The document will no longer be editable or dispatch "change" events.
*
* @param {!FileEntry} file Need not lie within the project.
* @param {!File} file Need not lie within the project.
* @param {!Date} initialTimestamp File's timestamp when we read it off disk.
* @param {!string} rawText Text content of the file.
*/
Expand All @@ -90,9 +90,9 @@ define(function (require, exports, module) {
Document.prototype._refCount = 0;

/**
* The FileEntry for this document. Need not lie within the project.
* If Document is untitled, this is an InaccessibleFileEntry object.
* @type {!FileEntry}
* The File for this document. Need not lie within the project.
* If Document is untitled, this is an InMemoryFile object.
* @type {!File}
*/
Document.prototype.file = null;

Expand Down Expand Up @@ -240,11 +240,16 @@ define(function (require, exports, module) {
if (useOriginalLineEndings) {
return this._text;
} else {
return this._text.replace(/\r\n/g, "\n");
return Document.normalizeText(this._text);
}
}
};

/** Normalizes line endings the same way CodeMirror would */
Document.normalizeText = function (text) {
return text.replace(/\r\n/g, "\n");
};

/**
* Sets the contents of the document. Treated as an edit. Line endings will be rewritten to
* match the document's current line-ending style.
Expand Down Expand Up @@ -415,16 +420,14 @@ define(function (require, exports, module) {

// TODO: (issue #295) fetching timestamp async creates race conditions (albeit unlikely ones)
var thisDoc = this;
this.file.getMetadata(
function (metadata) {
thisDoc.diskTimestamp = metadata.modificationTime;
$(exports).triggerHandler("_documentSaved", thisDoc);
},
function (error) {
this.file.stat(function (err, stat) {
if (!err) {
thisDoc.diskTimestamp = stat.mtime;
} else {
console.log("Error updating timestamp after saving file: " + thisDoc.file.fullPath);
$(exports).triggerHandler("_documentSaved", thisDoc);
}
);
$(exports).triggerHandler("_documentSaved", thisDoc);
});
};

/* (pretty toString(), to aid debugging) */
Expand Down Expand Up @@ -468,7 +471,7 @@ define(function (require, exports, module) {
* @return {boolean} - whether or not the document is untitled
*/
Document.prototype.isUntitled = function () {
return this.file instanceof NativeFileSystem.InaccessibleFileEntry;
return this.file instanceof InMemoryFile;
};


Expand Down
Loading