Open core-ai-bot opened 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?
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.
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:null
(_projectRoot
's initialized value)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 alwaysnull
unless I listen forprojectOpen
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 thenull
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.