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

Skip dropped files that are already open #4447

Merged
merged 2 commits into from
Jul 15, 2013
Merged
Changes from all commits
Commits
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
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