Skip to content

Commit

Permalink
Add support for PowerShell.ShowCodeActionDocumentation (#24)
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
deathaxe authored Oct 2, 2023
1 parent 3f8d011 commit 48c2750
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ def on_pre_server_command(self, command: Mapping[str, Any], done_callback: Calla
self._handle_show_references(references)
done_callback()
return True

if command_name == 'PowerShell.ShowCodeActionDocumentation':
self._handle_show_rule_documentation(command['arguments'][0])
done_callback()
return True

return False

def m_powerShell_executionStatusChanged(self, params: Any) -> None:
Expand Down Expand Up @@ -181,3 +187,15 @@ def _handle_show_references(self, references: List[Location]) -> None:
LocationPicker(view, session, references, side_by_side=False)
else:
sublime.status_message('No references found')

def _handle_show_rule_documentation(self, rule_id: str) -> None:
if not rule_id:
return

if rule_id.startswith("PS"):
rule_id = rule_id[2:]

sublime.run_command(
"open_url",
{"url": "https://docs.microsoft.com/powershell/utility-modules/psscriptanalyzer/rules/" + rule_id}
)

0 comments on commit 48c2750

Please sign in to comment.