brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

[CLOSED] Retrieve _projectRoot with no working files open #6513

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by le717 Saturday Mar 15, 2014 at 21:02 GMT Originally opened as https://github.com/adobe/brackets/issues/7206


(Pulled from #6878, primarily from https://github.com/adobe/brackets/pull/6878#issuecomment-36071520)

Issue 1 When no working files are open, running ProjectManager.getProjectRoot().name does one of two things:

  1. Returns null (_projectRoot's initialized value)
  2. If a project was previously opened, the previous project's name is returned until a working file is activated (if it ever is)

I believe this is the same problem that prevented #7123's unit test from working and from #6878 from completion.

Expected Return the proper project root at all possible times.

Issue 2 While trying to display the project title in the menu bar on Brackets load, I found it _projectRoot is always null unless I listen for projectOpen from ProjectManager to be fired (see https://github.com/le717/brackets/commit/e40428d63fa4ef8abba5a35ba7da8402c00e2e48 and https://github.com/le717/brackets/commit/8d5b35851076d1eacfc0dbd51c4c8a65c78c6ac7). I had to remedy this by setting an initial Project title of "Brackets", which is displayed for around 2 seconds (at least in my development, it could display longer) before the current project is loaded or issue 1 comes in, then a workaround keeps it at the initial value and prevents Brackets from never loading because of the null character. Take https://github.com/le717/brackets/tree/project-title out for a whirl to see for yourself.

Expected I am not quite sure how this one can be remedied, as the project root is indeed never known until a project is opened, be it manually or on program load. I figured I would report it anyway as it came up while I was working.

core-ai-bot commented 3 years ago

Comment by dangoor Wednesday Mar 19, 2014 at 18:44 GMT


Reviewed low priority to@peterflynn

core-ai-bot commented 3 years ago

Comment by peterflynn Wednesday Mar 19, 2014 at 19:38 GMT


@le717 As far as I can tell this is working correctly. If I put this code in an extension:

    $(ProjectManager).on("projectOpen", function () {
        console.log("OPEN: " + ProjectManager.getProjectRoot());
    });

The correct project is printed every time I switch projects, even if there are no files open in the "Working Files" list initially.

If you call getProjectRoot() immediately upon startup it will indeed return null since no project is open yet (see the note in its docs). You'll need to wait for either AppInit.appReady() or wait for the first "projectOpen" event.

Once that has occurred though, getProjectRoot() should never return null again -- are you seeing cases where it is?

core-ai-bot commented 3 years ago

Comment by peterflynn Tuesday Mar 25, 2014 at 20:58 GMT


Closing since there doesn't seem to be an actual bug in the API here. Can reopen if it turns out there is.