Copy diagnostic hover text#2618
Conversation
rchl
left a comment
There was a problem hiding this comment.
What about a case when the popup also shows other info like symbol documentation? Is the whole contents of the popup copied or each section is copied separately. If the latter then it would probably be hard to convey what is going to get copied.
…RATE_WITH_AUTO_COMPLETE
and get_copy_text_from_markup to markup_to_string
This comment was marked as outdated.
This comment was marked as outdated.
… the browser
when we copy the documentation, _on_navigate will be called and "url" will have the value "subl:lsp_copy_text {"text":"..."}" which is not a valid url
✅ Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This comment was marked as outdated.
This comment was marked as outdated.
copy_text_html returns a block element, before this commit, with the previous code, I moved the diagnostics source to be bellow the diagnostic message now the diagnostic message and source will be on the same line and look as before
This comment was marked as outdated.
This comment was marked as outdated.
Seems like this code cause <a><div>...</a></div> to be rendered and I suspect that the change to _render_label was the cause of it. F For now I will revert it
8f76525 to
18b26db
Compare
|
Latest update after c0957cb
|
|
FWIW, I do find the pngs approach nicer looking #2618 (comment) |
|
We are getting close with this, we just need to decide |
|
I do find the png approach nicer looking (because the icon is a bit bigger, a nicer looking, but it cannot be customized with css, and it does require more code) Based on the above messages, Rafal and Janos are leaning towards utf-8. (also no rush in the decision) |
I agree that utf-8 character looks a bit worse due to the fact that at least on Mac it looks a bit blurry at default 1rem. It looks good at 1.2rem but then it makes line height taller... I don't see a way to fix that with limited minihtml capabilities. I would still take utf-8 version for its simplicity and versatility. |
|
If I click the copy icon in the popup when hovering the gutter icon, a webbrowser (which is not even my default browser) opens... |
|
Nice catch. Found the reason ->
|
| 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()) |
There was a problem hiding this comment.
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>"""
jwortmann
left a comment
There was a problem hiding this comment.
One thing I noticed is that the copied text can contain for example non-breaking space characters. But this happens because the server (in this case Pyright) already contains these characters as \n\xa0\xa0 in the JSON payload, assumingly to enforce indentation after a linebreak, which would otherwise not get through the HTML rendering in the popup. Perhaps we should filter out/replace such characters? On the other hand that would feel a bit arbitrary and ultimatively it's the responsibility of the server what it puts into the diagnostic message.
I had code for this, but I reverted it because later I could not find the exact example on why I added the code in the first place baed32c I am in favor of replacing such chars, I think it benefits the user. |
|
Hello, if there are no further comments, I will merge this PR tonight. |







This is a POC that could address #2600
Sublime.Text.mp4
This enables coping hover responses from server,
and diagnostics text, at the moment.
TODO:
closes #2600