Skip to content

Commit

Permalink
Show diagnostics with code actions even when icon disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann committed Nov 1, 2023
1 parent c38f287 commit 143d6f6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plugin/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def _setup(self) -> None:
self._stored_selection = []
self._sighelp = None # type: Optional[SigHelp]
self._lightbulb_line = None # type: Optional[int]
self._diagnostics_by_config = [] # type: List[Tuple[SessionBufferProtocol, List[Diagnostic]]]
self._actions_by_config = [] # type: List[CodeActionsByConfigName]
self._registered = False

Expand Down Expand Up @@ -480,10 +481,17 @@ def _on_hover_gutter_async(self, point: int) -> None:
content = ''
if self._lightbulb_line == self.view.rowcol(point)[0]:
content += code_actions_content(self._actions_by_config)
if userprefs().diagnostics_gutter_marker and userprefs().show_diagnostics_severity_level:
if userprefs().show_diagnostics_severity_level:
diagnostics_with_config = [] # type: List[Tuple[ClientConfig, Diagnostic]]
diagnostics_by_session_buffer = [] # type: List[Tuple[SessionBufferProtocol, List[Diagnostic]]]
max_severity_level = min(userprefs().show_diagnostics_severity_level, DiagnosticSeverity.Information)
for sb, diagnostics in self.diagnostics_intersecting_async(self.view.line(point))[0]:
if userprefs().diagnostics_gutter_marker:
diagnostics_by_session_buffer = self.diagnostics_intersecting_async(self.view.line(point))[0]
elif content:
diagnostics_by_session_buffer = self._diagnostics_by_config
if content:
max_severity_level = userprefs().show_diagnostics_severity_level
for sb, diagnostics in diagnostics_by_session_buffer:
diagnostics_with_config.extend(
(sb.session.config, diagnostic) for diagnostic in diagnostics
if diagnostic_severity(diagnostic) <= max_severity_level
Expand Down Expand Up @@ -656,9 +664,9 @@ def _on_sighelp_navigate(self, href: str) -> None:
def _do_code_actions_async(self) -> None:
if not self._stored_selection:
return
diagnostics_by_config, covering = self.diagnostics_intersecting_async(self._stored_selection[0])
self._diagnostics_by_config, covering = self.diagnostics_intersecting_async(self._stored_selection[0])
actions_manager \
.request_for_region_async(self.view, covering, diagnostics_by_config, manual=False) \
.request_for_region_async(self.view, covering, self._diagnostics_by_config, manual=False) \
.then(self._on_code_actions)

def _on_code_actions(self, responses: List[CodeActionsByConfigName]) -> None:
Expand Down

0 comments on commit 143d6f6

Please sign in to comment.