-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ayoub Benali <[email protected]>
- Loading branch information
1 parent
80d5b96
commit 1366bbe
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from . lsp_metals_text_command import LspMetalsTextCommand | ||
from . utils import handle_error | ||
from LSP.plugin.core.protocol import Error | ||
from LSP.plugin.core.typing import Any | ||
from LSP.plugin.core.url import filename_to_uri # TODO: deprecated in a future version | ||
|
||
import sublime | ||
|
||
class LspMetalsCopyWorksheetCommand(LspMetalsTextCommand): | ||
|
||
_command_name = 'copy-worksheet-output' | ||
|
||
def is_enabled(self) -> bool: | ||
if super().is_enabled(None, None): | ||
return self.view.file_name().endswith('.worksheet.sc') | ||
else: | ||
return False | ||
|
||
def run(self, edit: sublime.Edit) -> None: | ||
file_name = self.view.file_name() | ||
session = self.session_by_name(self.session_name) | ||
if self.view.is_dirty(): | ||
sublime.message_dialog('Please save your worksheet before using this command.') | ||
elif session: | ||
uri = filename_to_uri(file_name) | ||
params = { | ||
"command": self._command_name, | ||
"arguments": [uri] | ||
} | ||
session.execute_command(params, progress=True).then(self._handle_response) | ||
|
||
def _handle_response(self, response: Any) -> None: | ||
if isinstance(response, Error): | ||
handle_error(self._command_name, response) | ||
elif 'value' in response: | ||
sublime.set_clipboard(response['value']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters