This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
I just discovered the React component click-to-component
. The component adds a visual overlay to your React application, allowing you to click on an element and jump right into your code base. Magic!
Obviously, there's some bundling and build magic involved to figure out the component file path, but I wondered how it opens the editor. Is the running server some shell commands?
Nope. All it does is open a URL with the editor's protocol. Here's an example URL that opens a file of my site.
vscode://file/Users/stefanjudis/Projects/github.com/stefanjudis/stefanjudis-website/index.html
Pretty cool! But where's this vscode
protocol coming from? On macOS apparently, applications can register URL handlers in the Info
file. Here's the responsible part I discovered in my /Applications/Visual Studio Code
.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>Visual Studio Code</string>
<key>CFBundleURLSchemes</key>
<array>
<string>vscode</string>
</array>
</dict>
</array>
</dict>
</plist>
How does it work on Windows? No idea... But if you do, let me know! I'd love to extend this post.
Reply to Stefan
This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
Stefan Judis | Sciencx (2024-11-10T23:00:00+00:00) How to open a local file from the URL bar in VS Code (#tilPost). Retrieved from https://www.scien.cx/2024/11/10/how-to-open-a-local-file-from-the-url-bar-in-vs-code-tilpost/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.