Skip to content

Commit

Permalink
fix #47, partially fix #46
Browse files Browse the repository at this point in the history
  • Loading branch information
t-mullen committed Jul 10, 2017
1 parent f5c6c76 commit 1e54ed7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions lib/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define(function (require, exports, module) {
var CommandManager = brackets.getModule('command/CommandManager')
var Commands = brackets.getModule('command/Commands')
var FileUtils = brackets.getModule('file/FileUtils')
var MainViewManager = brackets.getModule('view/MainViewManager')

var EditorWrapper = require('./editor')

Expand Down Expand Up @@ -38,6 +39,8 @@ define(function (require, exports, module) {
for (var i = 0; i < allFiles.length; i++) {
;(function (i) {
allFiles[i].read(function (err, contents, stat) {
if (err) return console.error(err)

var filePath = FileUtils.getRelativeFilename(
EditorWrapper.projectPath,
allFiles[i].fullPath
Expand Down Expand Up @@ -116,6 +119,8 @@ define(function (require, exports, module) {
self.changeQueues[absPath] = [change]

self._buildPath(absPath, false, function () {
if (!self.changeQueues[absPath]) return

// Empty the queue that built up
while (self.changeQueues[absPath][0]) {
self._pushChangeToDocument(absPath, self.changeQueues[absPath].shift())
Expand Down Expand Up @@ -152,12 +157,12 @@ define(function (require, exports, module) {

FileSystemWrapper.prototype._pushChangeToDocument = function (absPath, change, saveAfter) {
var self = this

var isWorkingFile = !!MainViewManager.findInAllWorkingSets(absPath).length

return DocumentManager.getDocumentForPath(absPath).then(function (doc) {
console.log(change.fn)
if (change.fn === 'setValue') {
doc._ensureMasterEditor()
doc._masterEditor._codeMirror.setValue(change.content)
doc.refreshText(change.content, doc.diskTimestamp, true)
} else if (change.fn === 'replaceRange') {
doc.replaceRange(change.text, change.from, change.to)
} else {
Expand All @@ -168,6 +173,10 @@ define(function (require, exports, module) {
CommandManager.execute(Commands.FILE_SAVE, {doc: doc}).then(noop).fail(noop)
ProjectManager.refreshFileTree()
}

if (!isWorkingFile) {
CommandManager.execute(Commands.FILE_CLOSE_LIST, {fileList: [doc.file]});
}
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Multihack",
"description": "Realtime collaboration for programmers. ALPHA",
"homepage": "https://github.com/RationalCoding/multihack-brackets",
"version": "4.2.3",
"version": "4.2.4",
"author": "Thomas Mullen",
"license": "MIT",
"scripts": {
Expand Down

0 comments on commit 1e54ed7

Please sign in to comment.