Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Quick Fix label in hover popup with lightbulb icon #2567

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added icons/lightbulb_colored.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugin/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def on_hover(self, point: int, hover_zone: int) -> None:
def _on_hover_gutter_async(self, point: int) -> None:
content = ''
if self._lightbulb_line == self.view.rowcol(point)[0]:
content += code_actions_content(self._code_actions_for_selection)
content += code_actions_content(self._code_actions_for_selection, lightbulb=False)
if userprefs().show_diagnostics_severity_level:
diagnostics_with_config: list[tuple[ClientConfig, Diagnostic]] = []
diagnostics_by_session_buffer: list[tuple[SessionBufferProtocol, list[Diagnostic]]] = []
Expand Down
6 changes: 4 additions & 2 deletions plugin/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def link(self, point: int, view: sublime.View) -> str:
]


def code_actions_content(actions_by_config: list[CodeActionsByConfigName]) -> str:
def code_actions_content(actions_by_config: list[CodeActionsByConfigName], lightbulb: bool = True) -> str:
formatted = []
for config_name, actions in actions_by_config:
action_count = len(actions)
Expand All @@ -95,8 +95,10 @@ def code_actions_content(actions_by_config: list[CodeActionsByConfigName]) -> st
text = actions[0].get('title', 'code action')
href = "{}:{}".format('code-actions', config_name)
link = make_link(href, text)
lightbulb_html = '<span class="lightbulb"><img src="res://Packages/LSP/icons/lightbulb_colored.png"></span>' \
if lightbulb else ''
formatted.append(
f'<div class="actions">Quick Fix: {link} <span class="color-muted">{config_name}</span></div>')
f'<div class="actions">{lightbulb_html}{link} <span class="color-muted">{config_name}</span></div>')
return "".join(formatted)


Expand Down
7 changes: 7 additions & 0 deletions popups.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
color: var(--foreground);
padding: 0.5rem;
}
.actions .lightbulb {
padding-right: 0.3rem;
}
.actions .lightbulb img {
width: 0.9em;
height: 0.9em;
}
.actions a.icon {
text-decoration: none;
}
Expand Down
Loading