Skip to content
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

feat: enable it to open multiple files #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CatBraaain
Copy link

Enable it to open multiple files

It's possible to get all selected files when running open command from context menu on explorer.
Here is a related code snippet on Stack Overflow:

Test

  1. Select two text files.
  2. Run open command from context menu.
  3. Two text files opened.
    test-video

I'm very new to pull request, I welcome any feedback.

@@ -48,7 +48,16 @@ class OpenController implements vscode.Disposable {
this._disposable.dispose();
}

private open(uri: vscode.Uri | undefined): void {
private open(uri: vscode.Uri | undefined, uris: vscode.Uri[] | undefined): void {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should look at combining these parameters into one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing.

Do you mean removing uri parameter and use only uris parameter like as below

  this.open(uris);
  ---
  private open(uris: vscode.Uri[] | undefined): void {

or combining two parameters into one as tuple like as below.

  this.open(uri, uris);
  ---
  private open(uriArgs: [vscode.Uri | undefined, vscode.Uri[] | undefined]): void {

If the former, it might be good but I am still not sure callback function always has uris parameter when it has uri parameter. Because it's not described clearly in reference.
What I found is only this as below.

Note 1: When a command is invoked from a (context) menu, VS Code tries to infer the currently selected resource and passes that as a parameter when invoking the command. For instance, a menu item inside the Explorer is passed the URI of the selected resource and a menu item inside an editor is passed the URI of the document.
vscode api reference

If the latter, I don't understand why.

If the other, could you explain me more detail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a case, when selecting folder, uri argument has a value, but uris argument is undefined.
so that we need both of uri and uris parameter in my opinion.

@CatBraaain CatBraaain force-pushed the enable-it-to-open-multiple-files branch from 79df80d to 0237175 Compare September 17, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants