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

Conversation

bchintx
Copy link
Contributor

@bchintx bchintx commented Aug 9, 2013

Overview

This change implements the Edge Code and Brackets user stories that allow Brackets to support the Windows Explorer "Open With..." command.

Please note that we still need an installer change to (1) pre-populate the necessary Registry entries prior to first launch; and (2) clean up the ProgID entries on Brackets uninstallation. However, even without these installer changes, the "Open With..." feature will still work, so long as you launch Brackets at least once before attempting to "open with..." a file.

Example Workflows

  1. install Brackets (or launch Brackets at least once)
  2. launch Windows Explorer
  3. browse to and select a supported file (eg. a .js file)
  4. right-click and choose "Open With..."
  5. select Brackets.exe from the resulting context menu or dialog (note: depending on whether other applications have also associated themselves with this file type, you might either see a dialog or context menu from which to select Brackets.exe)
  6. one of the following occur, depending on whether Brackets is already running:
    • if Brackets isn't already running, launches Brackets, opens selected file, and adds it to the working set;
    • if exactly one instance of Brackets is already running, opens selected file in that instance of Brackets, and adds it to the working set; or
    • if >1 instance of Brackets is already running, opens selected file in the top-most (ie. most recently used) instance of Brackets, and adds it tot he working set.

[note: Brackets Sprint 28 already supports opening a single file from the Brackets command-line. However, it always launches a new instance to open the given file.]

Implementation

This Windows-only, brackets-shell change adds two, new pieces of functionality:

  1. opens given file in the most-recent running instance, rather than launching a new Brackets window; and
  2. adds initialization/update of file association entries in the Windows Registry

For the first item, I've added a mutex to track when a Brackets instance is already running. Then, when a new file is opened from the command-line, the new instance will enumerate any already running instances of Brackets, starting with the top-most window instance (aka the most-recently used window), bring it to the front of the desktop windows, and send it the filename via a WM_COPYDATA message. Then, the second instance will immediately exit. Upon receipt of the WM_COPYDATA message, the receiving instance of Brackets will then call existing Javascript code to open the file and add it to the working set.

For the second item, I've added initialization code to create/update Registry entries corresponding to those associated with an application ProgID and individual Explorer FileExts entries in support of the "Open With..." command. This extra measure of initialization/update will help keep Brackets up-to-date, if for example you are running different builds of Brackets, without requiring that you uninstall and reinstall the application in order to continue using the "Open With..." command.

@bchintx
Copy link
Contributor Author

bchintx commented Aug 9, 2013

@jasonsanjose @peterflynn @gruehle can at least one of y'all please review this brackets-shell, Windows-only change too? Thanks!

@bchintx
Copy link
Contributor Author

bchintx commented Aug 13, 2013

Just submitted changes to the Windows installer scripts to have the installer create the Registry entries needed to associate the file types on application install.

All ready for review now. @gruehle @jasonsanjose @ingorichter @couzteau @peterflynn Can someone please review? Thanks in advance!

@ghost ghost assigned JeffryBooher Aug 14, 2013
@njx
Copy link

njx commented Aug 14, 2013

@gruehle pointed out that it looks like this pull request has the binary .msi files in it, which we don't want in the repo. We actually want them to go away from the git database entirely to keep the repo size small. There's no direct way to do that now that they're in this commit stream (even if you add a new commit removing them from this branch, if we later merge it as-is, the commit that added them will still be in the database, so the binaries will still be floating around in there). So, what we need to do is create a new branch with a squashed commit that doesn't have the binaries in them, then delete this branch. Eventually, git's GC will make the unreferenced commits go away.

I think the easiest way to do that is:

  • on your local machine, checkout this branch
  • copy the .msi files aside if you want to save them
  • git rm the .msi files from within the repo
  • git commit to add a commit to this branch that removes the msis
  • git checkout master
  • git checkout -b bchin/new-branch-name (whatever name you want for the new branch) to create a new clean branch off master
  • git merge --squash bchin/open-with-brackets-from-windows-explorer - that will do an initial merge of all the changes from the commits in this branch into your new branch, but won't actually create a commit
  • git commit to create the squashed merge commit. You now have a new branch with a single commit that contains all the changes from this branch (but without the msis, since you removed them).
  • git push -u origin bchin/new-branch-name
  • Create a pull request from the new branch and make sure it looks correct.
  • Delete this pull request and delete this branch from the github repo. (You can delete it from your local repo too, but I'd keep it around until you've verified that the new pull request looks ok, in case something goes wrong.)

@jasonsanjose
Copy link
Member

@peterflynn logged a similar bug for a mistake I made adobe/brackets#4423

@bchintx
Copy link
Contributor Author

bchintx commented Aug 14, 2013

Oops. I did not mean to commit the .msi to that branch. Thanks for catching that, @JeffryBooher and @jasonsanjose . Also, thanks for the steps @njx to create the new branch.

I've re-submitted this change as Pull Request #299. I'll close out and delete this branch as instructed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants