-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get selected file/folder in the explorer view #3553
Comments
@jrieken fyi |
This would be helpful for my vscode-hexdump extension, to retrieve selected file not compatible with TextDocument (i.e. png, jpg, ...). I wouldn't need to show an inputbox to ask for the file path everything :) |
Some extension need retrieve selected file/folder, such as TortoiseSVN. |
Maybe the
|
@jrieken executing a command from the menu, I get the uri as expected, except it doesn't work when that command is invoked from a KB shortcut (I get an empty parameter instead). |
Yeah, thats the design of things as KB shortcuts are global (not contextual) by definition... It's like someone using you command-id with the |
with some api or not? |
I find out a way to get the path of selected folder. You can contribute a menu of explorer,then run the vscode.commands.executeCommand('copyFilePath');. You can get the value into your clipboard |
@jrieken Do you have an idea for API? Something like |
no |
I too need this function for a plugin. Has forecast for implementation? In Theia was implemented. |
I need this feature now. Has it ever been implemented or is there another way to get the selected items in the explorer view? I need to search for specific files but only in the currently selected folder. |
Any progress on this api? I think this is a very basic api. |
Yes I need that as well in part of my vscode. I need to get the list of files or folders selected by the user. Is there any update on this ticket ? |
I found this solution. It wasn't very clear from docs that register command passes a URI which can then be used for getting the path of the selected file when activating your command from the context menu in the explorer export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "My-lite-switcher" is now active!');
let disposable = vscode.commands.registerCommand('My-lite-switcher.activate', (uri:vscode.Uri) => {
let f = uri.fsPath;
vscode.window.showInformationMessage(`My Lite Switcher: ${f}`);
});
context.subscriptions.push(disposable);
} |
Does the new tabs API help anyone here? That's not limited by the text document and can get you the open file which is often the same as the selected file. I'm trying to understand the use cases in this thread and it seems like at least most would be solved with the tabs API. |
I think they mean the file or folder which was clicked in the explorer view, or selected with the keyboard, not the open editor. |
could you convert it to js |
this solution from @JeremyFunk is the closest i found to work, but there is still some situations where it doesn't work
|
Indeed, this API is very basic and should be exposed. I hope vscode can support it. |
I need this too! Any updates please? |
This can be very easily achieved - please follow my post on StackOverflow |
Please take a closer look at our question, we are talking about the file or folder which was clicked in the explorer view, or selected with the keyboard, not the open editor. |
I agree with Simon-He95. Getting the URI for an Explorer Context menu right mouse click is already present in vscode. What is needed is a URI notification for a left mouse click event on a folder. Something like this proposed API for a Treeview would be fantastic: The In fact, vscode's own git implementation could use this feature. If I have a multi-rooted workspace, with subfolders containing repos, vscode git will always use the topmost folder as the git repo. It should use the repo of the currently selected folder in Explorer. |
adding my 2 cents: such an event emitter would be great to implement the most basic "Show README" for selected folder, a very useful feature when browsing large repos. This is exactly what GITHUB does whenever a folder is selected, the relevant README file is displayed. Would Love Love to get this same feature for vscode. I have the code ready for this (currently implemented as right-click context menu, but that's really a pita). |
I would love to be able to add keybindings for these commands but can't because the extension can't currently support getting the current file list from the explorer. :< |
Now, is there such an API? I need to use it too. |
Sadly the workaround where you copy clipboard, load path to clipboard, retrieve it, and restore state has two unacceptable issues for me.
Thus, add me to the bucket of people who are trying to show a README.md for a folder in my extension panel, with no way of being able to tell when a folder is selected by a left click. |
It would be nice if it was possible to retrieve the selected file/folder in the explorer view. The use case where I want to use it for is my
vscode-yo
extension to be able to run the generator in the selected directory. An API for this would be nice.The text was updated successfully, but these errors were encountered: