I want to write a Sidebar extension that lets you bookmark any file or folder in your project, and expand/collapse/open them in the extension’s sidebar.
Problem 1: It seems the only way for a user to provide a file or especially a folder to a command is to use nova.workspace.showFileChooser(). It would be very nice if we could put commands in the contextual menu of Files sidebar items, but that doesn’t seem to be an option.
Problem 2: showFileChooser doesn’t seem to actually allow you to choose folders. No matter what combination of other options I try, specifying allowDirectories: true doesn’t put the macOS file picker in the mode that lets you return folders; it’s always in the mode where clicking the OK button with a folder selected navigates into the folder, and with nothing selected the OK button is grayed out.
Would love some pointers toward workarounds or even telling me I’m badly missing something.
Ahh, thank you! And yes, consider this a request for that extension point. You could also just Sherlock me and allow multiple project folders in the main Files sidebar if you wanted
. If this is on purpose for some reason then that’s cool, since the nova.path.normalize function exists. But perhaps it would be better for it to be normalized by default? I dunno.
I’ve run into issues with /Volumes/Macintosh HD/ a few times. My main problem is that I generally need to strip it, but can’t really guarantee the name of the volume, if someone’s on a custom setup. I think the most reliable thing is to split by /, remove those bits, and rejoin the path. I’d really like it if path.normalize handled either consistently adding it or removing it for me, though.