-
Notifications
You must be signed in to change notification settings - Fork 617
Initial implementation of drag and drop to open files #190
Conversation
This works great on Windows. Currently, Brackets always opens to the last opened project. It would be nice if Brackets detected that the file you dropped on it is contained in one of the projects in your recent projects list and automatically switched to that project. UPDATE: ... only if Brackets is starting up (not when it's already open). |
// This should probably be made more robust... | ||
|
||
return (str.find_first_of(':') != std::string::npos && | ||
str.find_first_of('.') != std::string::npos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not common, but some files don't have an extension, so you shouldn't check for dot.
You should also make sure there are no characters that are not valid in file names. Take a look at the _checkForValidFilename() function in ProjectManager.js for a list of chars to check for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced this code with a call to GetFileAttributes()
. If the call succeeds, we can safely assume it is a valid filename :-)
On Mac, when I right-click, in the Open With sub-menu, the entry I see is "Brackets.app ()". Seems like there should no be any parens if they're empty. |
On Mac, I've seen a few crashes with "Brackets quit unexpectedly" message, but I have not been able to find a reproducible pattern. |
I'm not sure I agree... many times I want to open a file from a different project without changing the current project. I plan on adding support for dropping folders, which will either switch to that folder or open a new Brackets window showing the dropped folder (haven't figured out which is better yet..). |
Do you know how to control that? I saw the parens at first too, but I no longer see them on my mac. |
Allow me to qualify that some more. I don't think Brackets should switch projects if it is already open. I would only want Brackets to switch projects in the case where it is starting up to display a particular file. |
Ah, okay. That makes sense--thanks for clarifying. I'd rather leave that for a subsequent pull request if that's okay with you. |
Wow, this really sucks trying to have multiple conversations with no threading :) The empty paren thing seems to happen when right-clicking on a file that has a default app defined which is something other than Brackets. When I right-click on a .html file I see entries for "Safari.app (default)" and "Brackets.app ()". When I right-click on a .css file I see entries for "Brackets.app (default)" and "Safari.app". |
Done with initial review. |
The parens show up for some file types, but not for others. If I right-click a markdown file, Sublime is the default app, and Brackets shows up without "()". If I right-click a .css file, Brackets shows up with "()". I don't know why. |
Changes pushed. |
<key>LSItemContentTypes</key> | ||
<array> | ||
<string>public.text</string> | ||
<string>public.source-code</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indenting in this file is not consistent (mix of spaces and tabs?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Not sure how important this is, but if you don't have setup_for_hacking setup (which gets cleared every time I do a build on Mac), and you drop a file on icon, Brackets is opened, but the file is forgotten. |
…ckets-shell into glenn/file-association
Done with second review. I sent a crash log with the first review, and saw another crash just now. Any ideas about that? |
I can consistently reproduce the mac crash now with the following steps:
Unfortunately, I haven't been able to determine a fix yet, so this shouldn't be merged until I have time to fix the crash. |
@redmunds - I finally fixed the crash on quit bug. This pull request is now ready for final review. |
I can no longer reproduce crash. Last question I have is, what do you think about the "if you don't have setup_for_hacking setup (which gets cleared every time I do a build on Mac), and you drop a file on icon, Brackets is opened, but the file is forgotten" issue? |
I'm not really worried about it. You can drop files onto a running instance of Brackets in that case, so it only affects a minor use case for a small number of users. |
Looks good. Merging. |
Initial implementation of drag and drop to open files
Initial implementation of drag and drop to open files
The pull request adds an initial implementation of file association and drag and drop to open files.
Implemented on the Mac:
These work whether or not Brackets is already running
Missing on Mac: drag and drop onto a Brackets window. Chromium is swallowing all drag events so they never make it to the native shell.
Implemented on Windows:
Missing on Windows: Right click and select Open With > Brackets.exe. This requires registry modifications that would be best to do from the installer.
NOTE: There will be a corresponding brackets pull request that is required to open files at launch time.