Skip to content

Commit

Permalink
Merge pull request #128 from kyleect/more-vsc-commands
Browse files Browse the repository at this point in the history
Add more vsc commands to open code in the playground
  • Loading branch information
kyleect authored Jan 1, 2024
2 parents c8a71cc + e63c86f commit f96f726
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions vsc/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ServerOptions,
} from "vscode-languageclient/node";
import { LocksTaskProvider } from "./locksTaskProvider";
import { compressToEncodedURIComponent } from "lz-string";

let lc: LanguageClient;

Expand Down Expand Up @@ -120,6 +121,15 @@ export function activate(context: ExtensionContext) {
}),
commands.registerCommand("locks.openGithub", () => {
env.openExternal(Uri.parse("https://github.com/kyleect/locks"));
}),
commands.registerCommand("locks.openSelectedCodeInPlayground", () => {
const selection = window.activeTextEditor.selection;
const selectedText = window.activeTextEditor.document.getText(selection);
const code = compressToEncodedURIComponent(selectedText);

env.openExternal(
Uri.parse(`https://kyleect.github.io/locks/#/?code=${code}`)
);
})
);

Expand Down
9 changes: 9 additions & 0 deletions vsc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
"command": "locks.openPlayground",
"title": "Locks: Open Playground"
},
{
"command": "locks.openSelectedCodeInPlayground",
"title": "Locks: Open Selected Code In Playground"
},
{
"command": "locks.openGithub",
"title": "Locks: Open On Github"
Expand All @@ -115,6 +119,7 @@
"vsce": "^2.15.0"
},
"dependencies": {
"lz-string": "^1.5.0",
"vscode-languageclient": "9.0.1"
},
"scripts": {
Expand Down

0 comments on commit f96f726

Please sign in to comment.