From 8f505fe056d7322721cde335f35e61afb2270a0c Mon Sep 17 00:00:00 2001 From: jwortmann Date: Mon, 9 Dec 2024 10:50:13 +0100 Subject: [PATCH] Replace Quick Fix label in hover popup with lightbulb icon (#2567) --- icons/lightbulb_colored.png | Bin 0 -> 826 bytes plugin/documents.py | 2 +- plugin/hover.py | 6 ++++-- popups.css | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 icons/lightbulb_colored.png diff --git a/icons/lightbulb_colored.png b/icons/lightbulb_colored.png new file mode 100644 index 0000000000000000000000000000000000000000..c06e86d04b36a7bbafe12e7ec0ee6d101395b4e8 GIT binary patch literal 826 zcmV-A1I7G_P)?>2 zK~zYI&6dwk9Ay~CKhMlENJxrl4Y7^kVu}H3YrJr2BsErxY1-Z8hwCaXJc`olArGhVI1^Ad^fB) z4#TOlg>Ux^3jExVu#bUMb?P^X8)o_)Gm~gD;|)aHR*4zI4e7!sb%Qqj{7FMstB`x3 zOWsOHfzi?Mp~SH!Z*pF*+H+Ea(@Dz2mT_o<6hs?+HSW5 zpy=m1z?Omiz)f#`Ul+sU!S)&tDTx|WPzcyzF2rOM4 z{Nkkxvq_K#u$dX)R{*4RZ9EFp2_UoxNzeXvNx)+DqAL+(=m3Dp*6W9CvG}9n!83^< z!4}})o0 z&>g&zX<0UYU-h~l2gNPjo3w|o%i z6$@hEa#1iMST>Wtqu96(tP0+(eTmj8_QUr$l}bt|ex5&yqu$u0(5`uXQ!9@I!U;bG zdnq=@)my;Jj|MXPO5!;KH!3VB8^j)Hc#`&LOPhZFl%ZqW=Ok7evxO`5)YrA5;unLR zgzk@#!O)I)eN)k~ZHhlfRe5T@4MhDr-1NfIoq9a}2irFeECq&h6951J07*qoM6N<$ Ef*?G6kpKVy literal 0 HcmV?d00001 diff --git a/plugin/documents.py b/plugin/documents.py index e0ada4784..94c28ea79 100644 --- a/plugin/documents.py +++ b/plugin/documents.py @@ -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]]] = [] diff --git a/plugin/hover.py b/plugin/hover.py index f88ee1d47..26d48f82a 100644 --- a/plugin/hover.py +++ b/plugin/hover.py @@ -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) @@ -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 = '' \ + if lightbulb else '' formatted.append( - f'
Quick Fix: {link} {config_name}
') + f'
{lightbulb_html}{link} {config_name}
') return "".join(formatted) diff --git a/popups.css b/popups.css index 621bc11ea..1c761e9d9 100644 --- a/popups.css +++ b/popups.css @@ -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; }