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

Commit

Permalink
Merge pull request #4447 from adobe/glenn/issue-4429
Browse files Browse the repository at this point in the history
Skip dropped files that are already open
  • Loading branch information
Narciso Jaramillo committed Jul 15, 2013
2 parents a3e42d2 + 01008ef commit 6a65fdb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/utils/DragAndDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ define(function (require, exports, module) {
Commands = require("command/Commands"),
Dialogs = require("widgets/Dialogs"),
DefaultDialogs = require("widgets/DefaultDialogs"),
DocumentManager = require("document/DocumentManager"),
FileUtils = require("file/FileUtils"),
ProjectManager = require("project/ProjectManager"),
Strings = require("strings"),
Expand Down Expand Up @@ -73,12 +74,22 @@ define(function (require, exports, module) {
function openDroppedFiles(files) {
var errorFiles = [];

return Async.doInParallel(files, function (file) {
return Async.doInParallel(files, function (file, idx) {
var result = new $.Deferred();

// Only open files
brackets.fs.stat(file, function (err, stat) {
if (!err && stat.isFile()) {
// If the file is already open, and this isn't the last
// file in the list, return. If this *is* the last file,
// always open it so it gets selected.
if (idx < files.length - 1) {
if (DocumentManager.findInWorkingSet(file) !== -1) {
result.resolve();
return;
}
}

CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET,
{fullPath: file, silent: true})
.done(function () {
Expand Down

0 comments on commit 6a65fdb

Please sign in to comment.