diff --git a/boot.py b/boot.py
index 7c07c7455..17ef443f9 100644
--- a/boot.py
+++ b/boot.py
@@ -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
@@ -100,6 +101,7 @@
"LspCollapseTreeItemCommand",
"LspColorPresentationCommand",
"LspCommitCompletionWithOppositeInsertMode",
+ "LspCopyTextCommand",
"LspCopyToClipboardFromBase64Command",
"LspDisableLanguageServerGloballyCommand",
"LspDisableLanguageServerInProjectCommand",
diff --git a/plugin/completion.py b/plugin/completion.py
index 18e26e732..c254e5a52 100644
--- a/plugin/completion.py
+++ b/plugin/completion.py
@@ -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):
diff --git a/plugin/core/views.py b/plugin/core/views.py
index a2ba5c6d6..e47f8c5d5 100644
--- a/plugin/core/views.py
+++ b/plugin/core/views.py
@@ -831,6 +831,10 @@ 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)
+ copy_text = f"{diagnostic['message']} {f'({source})' if source else ''}".strip().replace(' ', ' ')
+ html += f"""⧉"""
if related_infos := diagnostic.get("relatedInformation"):
info = "
".join(_format_diagnostic_related_info(config, info, base_dir) for info in related_infos)
html += '
' + _html_element("pre", info, class_name="related_info", escape=False)
diff --git a/plugin/documents.py b/plugin/documents.py
index d0b5333e4..fd1a2fea4 100644
--- a/plugin/documents.py
+++ b/plugin/documents.py
@@ -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 --------------------------------------------------------------------------------------
@@ -786,8 +789,10 @@ def _on_navigate(self, href: str, point: int) -> None:
placeholder="Code actions")
else:
self.handle_code_action_select(config_name, actions, 0)
- else:
+ elif href.startswith("http"):
open_in_browser(href)
+ else:
+ debug('on_navigate unhandled href:', href)
def handle_code_action_select(self, config_name: str, actions: list[CodeActionOrCommand], index: int) -> None:
if index == -1:
diff --git a/plugin/hover.py b/plugin/hover.py
index 29ad0b136..514d4df5d 100644
--- a/plugin/hover.py
+++ b/plugin/hover.py
@@ -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
@@ -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")
diff --git a/popups.css b/popups.css
index 1c761e9d9..118d11344 100644
--- a/popups.css
+++ b/popups.css
@@ -86,3 +86,8 @@ 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));
+}