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

Copy extension link #234210

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

cachandlerdev
Copy link

Hi, I added a context menu item for "Copy Extension Link" in accordance with #233915. I'm afraid I'm not quite sure how to test it on extensions from the vscode marketplace because they don't show up when running ./scripts/code.sh, but the logic is copied from the "Copy" item above, and I believe it appropriately handles built-in extensions.

@cachandlerdev
Copy link
Author

@microsoft-github-policy-service agree

@SalerSimo
Copy link

@cachandlerdev If you go in the Extensions and you apply a filter some extension should show up.
I tried your code but i didnt get any url, what value is supposed to be wrote in the clipboard?

@cachandlerdev
Copy link
Author

cachandlerdev commented Nov 19, 2024

Hi, I noticed that behavior as well, but I believe it's the case because those extensions are built-in by default and don't have links. If you look at the existing "Copy" code, you'll see that no link gets created for those extensions. I tried to hide the context item altogether using the "when" keyword, but it didn't seem to apply to every built-in extension (e.g. Git).

I would separately test external marketplace extensions if I could to double check that the link functionality works on extensions with marketplace links, but I only was able to see built-in extensions from the application when using ./scripts/code.sh (even after applying various types of filters).

@SalerSimo
Copy link

I managed to install an extension, you have to download the .vsix extension file from the marketplace and then go there:
Screenshot 2024-11-19 224318
Even with this extension the function doesn't work, the parameter extension.url always seems to be 'undefined'

@cachandlerdev
Copy link
Author

cachandlerdev commented Nov 19, 2024

Ah, I see what you mean. However, this appears to be standard behavior for the "Copy" context menu item that I have not touched on this development version. I find this odd because when I run VSCode normally (not the development version), the URL is retrieved when clicking the "Copy" context menu item button.

Here is the result of clicking the normal "Copy" button in VSCode on that extension:

Name: Code Runner
Id: formulahendry.code-runner
Description: Run C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, CMD, BASH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET, Clojure, Haxe, Obj-C, Rust, Racket, Scheme, AutoHotkey, AutoIt, Kotlin, Dart, Pascal, Haskell, Nim, 
Version: 0.12.2
Publisher: Jun Han
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

And here's the result in the version I get when running ./scripts/code.sh:

Name: Code Runner
Id: formulahendry.code-runner
Description: Run C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, CMD, BASH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET, Clojure, Haxe, Obj-C, Rust, Racket, Scheme, AutoHotkey, AutoIt, Kotlin, Dart, Pascal, Haskell, Nim, D, Lisp, Kit, V, SCSS, Sass, CUDA, Less, Fortran, Ring, Standard ML, Zig, Mojo, Erlang, SPWN, Pkl, Gleam
Version: 0.12.2
Publisher: formulahendry

@SalerSimo
Copy link

Then instead of the "Copy" item you might copy the logic from "Copy Extension Id" and just add a prefix:

run: async (accessor: ServicesAccessor, extensionId: string) => {
      const clipboardService = accessor.get(IClipboardService);
      const extensionLinkPrefix = 'https://marketplace.visualstudio.com/items?itemName=';

      await clipboardService.writeText(extensionLinkPrefix + extensionId);
}

Something like this.

@cachandlerdev
Copy link
Author

Alright, I changed that code and corrected the when: condition to only display the menu item for extensions that aren't built-in (and as a result don't have marketplace links). The feature appears to be working now.

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.

3 participants