Skip to content
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
94d7b66
Copy hover response content and diagnostics text from the hover popup
predragnikolic Aug 16, 2025
17f0c5e
fix display of errors diagnostics
predragnikolic Aug 16, 2025
a57a692
prepend the source of the diagnostics when coping diagnostics
predragnikolic Aug 16, 2025
6e524fb
allow copying text from the popup that appears with completions COOPE…
predragnikolic Aug 16, 2025
7d4ade4
cover signature help
predragnikolic Aug 16, 2025
c0ba0a1
rename copy_text_html_element to copy_text_html
predragnikolic Aug 16, 2025
75b3549
remove unused imports
predragnikolic Sep 2, 2025
1d8a53a
set status message as the original copy command
predragnikolic Sep 2, 2025
03c6702
fix flake8
predragnikolic Sep 2, 2025
9765365
make copy_text not nullable
predragnikolic Sep 2, 2025
5a77bf4
inherit the color instead of overriding it
predragnikolic Sep 2, 2025
51417da
fix flake8
predragnikolic Sep 2, 2025
0a25dab
don't expose _markup_to_string and only expose copy_text_html
predragnikolic Sep 2, 2025
bc2a060
split import
predragnikolic Sep 2, 2025
ce73520
sublime.command_url already does html.unescape
predragnikolic Sep 3, 2025
ab65e90
this is the reason why copying content from the signature help opened…
predragnikolic Sep 3, 2025
95d0512
wrap both the diagnostic message and source in a block element
predragnikolic Sep 5, 2025
18b26db
don't handle signature help for now
predragnikolic Sep 10, 2025
8c5a999
Revert "don't handle signature help for now"
predragnikolic Sep 10, 2025
a6655ae
Signature help was actually working, but the tests needed to be updated
predragnikolic Sep 12, 2025
8198c66
Update plugin/core/views.py
predragnikolic Sep 13, 2025
6f52d0d
sort lines
predragnikolic Sep 13, 2025
0e4ce02
if instead of elif
predragnikolic Sep 13, 2025
baed32c
remove .replace(' ', ' ') as I cannot seem to find the example hover …
predragnikolic Sep 13, 2025
1eea3a8
move _markup_to_string after copy_text_html
predragnikolic Sep 13, 2025
1ae508b
rename copy_text_html to wrap_in_copy_link and call markup_to_string …
predragnikolic Sep 13, 2025
08ae8cb
Merge branch 'main' into feature/copy_hover_content
predragnikolic Oct 15, 2025
7b327aa
add debug logs when on_navigate logic is not handled
predragnikolic Oct 15, 2025
aa4be0f
Add copy button for each diagnostic, but remove ability to copy text …
predragnikolic Oct 15, 2025
f05e74a
Revert test changes
predragnikolic Oct 15, 2025
d128f6d
remove wrap_in_copy_link
predragnikolic Oct 15, 2025
5b6088e
Change the look of the copy button
predragnikolic Oct 15, 2025
3b3839c
revert as it was
predragnikolic Oct 15, 2025
e02f3db
Reduce the padding
predragnikolic Oct 15, 2025
7945e79
Merge branch 'main' into feature/copy_hover_content
predragnikolic Nov 11, 2025
efbdd30
Use an UTF char for the icon
predragnikolic Nov 11, 2025
d79f9a7
reduce the UTF icon(char) size
predragnikolic Nov 11, 2025
199e68c
Use ⧉ and remove text
predragnikolic Nov 11, 2025
3fbf73d
keep source at the end with parentheses
predragnikolic Nov 11, 2025
4e6d21f
move inline style for color: inherit to popups.css
predragnikolic Nov 11, 2025
89f3bab
use single quotes for consistency
predragnikolic Nov 11, 2025
096d29f
use space instead of  
predragnikolic Nov 11, 2025
09113ba
revert unnecessary change
predragnikolic Nov 11, 2025
6f9be2e
use pngs, they can be rendered successfully
predragnikolic Nov 12, 2025
87cf18b
adjust based on feedback
predragnikolic Nov 13, 2025
b0393ba
Copy -> Copy to clipboard
predragnikolic Nov 13, 2025
226e125
change LspCopyTextCommand to be a WindowCommand
predragnikolic Nov 13, 2025
ee173a7
change class names
predragnikolic Nov 13, 2025
c0957cb
adjust based on latest feedback
predragnikolic Nov 13, 2025
fa851c0
remove font-size: 1rem
predragnikolic Nov 13, 2025
478f64c
remove span
predragnikolic Nov 13, 2025
fd2c7e0
add "on_navigate unhandled href"
predragnikolic Nov 13, 2025
5726cd6
inline code
predragnikolic Nov 14, 2025
b2791ce
remove line at the end of popups.css
predragnikolic Nov 14, 2025
13be4ea
replace OxaO with a space char
predragnikolic Nov 14, 2025
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
2 changes: 2 additions & 0 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from .plugin.hierarchy import LspCallHierarchyCommand
from .plugin.hierarchy import LspHierarchyToggleCommand
from .plugin.hierarchy import LspTypeHierarchyCommand
from .plugin.hover import LspCopyTextCommand
from .plugin.hover import LspHoverCommand
from .plugin.hover import LspToggleHoverPopupsCommand
from .plugin.inlay_hint import LspInlayHintClickCommand
Expand Down Expand Up @@ -100,6 +101,7 @@
"LspCollapseTreeItemCommand",
"LspColorPresentationCommand",
"LspCommitCompletionWithOppositeInsertMode",
"LspCopyTextCommand",
"LspCopyToClipboardFromBase64Command",
"LspDisableLanguageServerGloballyCommand",
"LspDisableLanguageServerInProjectCommand",
Expand Down
7 changes: 5 additions & 2 deletions plugin/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,11 @@ def _format_documentation(
) -> str:
return minihtml(self.view, content, FORMAT_STRING | FORMAT_MARKUP_CONTENT, language_map)

def _on_navigate(self, url: str) -> None:
webbrowser.open(url)
def _on_navigate(self, href: str) -> None:
if href.startswith("http"):
webbrowser.open(href)
return
debug('on_navigate unhandled href:', href)


class LspCommitCompletionWithOppositeInsertMode(LspTextCommand):
Expand Down
9 changes: 9 additions & 0 deletions plugin/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,22 @@ def format_diagnostic_for_html(config: ClientConfig, diagnostic: Diagnostic, bas
meta_info += "({})".format(
make_link(code_description["href"], str(code)) if code_description else text2html(str(code)))
html += " " + _html_element("span", meta_info, class_name="color-muted", escape=False)
html += copy_icon_html(f"{diagnostic['message']} {f'({source})' if source else ''}".strip())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function could be inlined, since it consists of only a single expression and is not used elsewhere:

copy_text = f"{diagnostic['message']} {f'({source})' if source else ''}".strip()
html += f"""<a class='copy-icon' title='Copy to clipboard' href='{sublime.command_url(
        'lsp_copy_text', {'text': copy_text}
    )}'>⧉</a>"""

if related_infos := diagnostic.get("relatedInformation"):
info = "<br>".join(_format_diagnostic_related_info(config, info, base_dir) for info in related_infos)
html += '<br>' + _html_element("pre", info, class_name="related_info", escape=False)
severity_class = DIAGNOSTIC_SEVERITY[diagnostic_severity(diagnostic) - 1][1]
return _html_element("pre", html, class_name=severity_class, escape=False)


def copy_icon_html(text_to_copy: str) -> str:
return f"""<a class='copy-icon'
title='Copy to clipboard'
href='{sublime.command_url('lsp_copy_text', {
'text': text_to_copy
})}'><span>⧉</span></a>"""
Comment thread
predragnikolic marked this conversation as resolved.
Outdated


def format_code_actions_for_quick_panel(
session_actions: Iterable[tuple[str, CodeAction | Command]]
) -> tuple[list[sublime.QuickPanelItem], int]:
Expand Down
5 changes: 4 additions & 1 deletion plugin/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,10 @@ def _on_sighelp_hide(self) -> None:
self._sighelp = None

def _on_sighelp_navigate(self, href: str) -> None:
webbrowser.open_new_tab(href)
if href.startswith("http"):
webbrowser.open_new_tab(href)
return
debug('on_sighelp_navigate unhandled href:', href)

# --- textDocument/codeAction --------------------------------------------------------------------------------------

Expand Down
9 changes: 8 additions & 1 deletion plugin/hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def diagnostics_content(self) -> str:
return "".join(formatted)

def hover_content(self) -> str:
contents = []
contents: list[str] = []
for hover, language_map in self._hover_responses:
content = (hover.get('contents') or '') if isinstance(hover, dict) else ''
allowed_formats = FORMAT_MARKED_STRING | FORMAT_MARKUP_CONTENT
Expand Down Expand Up @@ -409,3 +409,10 @@ def _update_views_async(self, enable: bool) -> None:
session_view.view.settings().set(SHOW_DEFINITIONS_KEY, False)
else:
session_view.reset_show_definitions()


class LspCopyTextCommand(sublime_plugin.WindowCommand):
def run(self, text: str) -> None:
sublime.set_clipboard(text)
text_length = len(text)
self.window.status_message(f"Copied {text_length} characters")
6 changes: 6 additions & 0 deletions popups.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ pre.related_info {
margin-top: 0.7rem;
padding-top: 0.7rem;
}
a.copy-icon {
padding: 0.5rem;
text-decoration: none;
color: color(var(--foreground) alpha(0.6));
}