Skip to content

Commit

Permalink
Merge pull request #466 from ckipp01/copyWorksheets
Browse files Browse the repository at this point in the history
Add in metals.copy-worksheet-ouput command
  • Loading branch information
tgodzik authored Dec 19, 2020
2 parents 1e0093e + ce52d3a commit 827bd7e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@
"command": "metals.toggle-show-inferred-type",
"category": "Metals",
"title": "Toggle showing inferred type"
},
{
"command": "metals.copy-worksheet-output",
"category": "Metals",
"title": "Copy worksheet output"
}
],
"menus": {
Expand Down Expand Up @@ -561,7 +566,7 @@
"vsce": "1.83.0"
},
"dependencies": {
"metals-languageclient": "0.3.4",
"metals-languageclient": "0.4.0",
"promisify-child-process": "4.1.1",
"vscode-languageclient": "6.1.3"
},
Expand Down
27 changes: 27 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,33 @@ function launchMetals(
});
});

registerTextEditorCommand(
`metals.${ServerCommands.CopyWorksheetOutput}`,
(editor, _edit, _args) => {
const uri = editor.document.uri;
if (uri.toString().endsWith("worksheet.sc")) {
client
.sendRequest(ExecuteCommandRequest.type, {
command: ServerCommands.CopyWorksheetOutput,
arguments: [uri.toString()],
})
.then((result) => {
window.showInformationMessage(result);
if (result.value) {
env.clipboard.writeText(result.value);
window.showInformationMessage(
"Copied worksheet evaluation to clipboard."
);
}
});
} else {
window.showWarningMessage(
"You must be in a worksheet to use this feature."
);
}
}
);

registerCommand("metals.goto-path-uri", (...args) => {
const uri = args[0] as string;
const line = args[1] as number;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ mdurl@^1.0.1:
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=

metals-languageclient@0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/metals-languageclient/-/metals-languageclient-0.3.4.tgz#8e7c385989c34790db2d419e713e292a2ed846bb"
integrity sha512-czntG51hDwGUacM6SHqn9JnMRbBBHF2tHIntTCnYuHuIanOpqsdyO6Q+jQJ/zlKl0R/wRNtslMh6rXquiBAwrw==
metals-languageclient@0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/metals-languageclient/-/metals-languageclient-0.4.0.tgz#99df12b3776ceb0ad0a05a67f628b1ea89cd8ba0"
integrity sha512-gvQ1NYkV7u0dbA59STd9Hleor23vztQY8WaIgDO1udb7tJM/NrS7ZLLxY9H6CDwoMiZhXaUvlpCjGwn/t8qTzg==
dependencies:
fp-ts "^2.4.1"
locate-java-home "^1.1.2"
Expand Down

0 comments on commit 827bd7e

Please sign in to comment.