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

fix completion documentation being parsed as markdown twice #2146

Merged
merged 1 commit into from
Dec 21, 2022

Conversation

rchl
Copy link
Member

@rchl rchl commented Dec 20, 2022

Based on investigation in sublimelsp/LSP-pyright#207.

I believe this is correct since minihtml_content is built from parts that should have already gone through mdpopups markdown parsing but I might have missed something.

Copy link
Member

@predragnikolic predragnikolic left a comment

Choose a reason for hiding this comment

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

class LspResolveDocsCommand(LspTextCommand):
    def _handle_resolve_response_async():
    	#...
        documentation = self._format_documentation(item.get("documentation") or "", language_map) # <- _format_documentation
        if documentation:
            minihtml_content += documentation

        def run_main() -> None:
            if self.view.is_popup_visible():
                update_lsp_popup(self.view, minihtml_content, md=True) # <-
            else:
                show_lsp_popup(
                    ...
                    md=True, # <-

    def _format_documentation():
        return minihtml()


def minihtml():
   	# ...
    if is_plain_text:
        return "<p>{}</p>".format(text2html(result)) if result else ''
    else:
        return mdpopups.md2html(view, mdpopups.format_frontmatter(frontmatter) + result)

just a personal note:

We do not need to enable md=True for update_lsp_popup and show_lsp_popup
because minihtml_content markdown is already transformed to html with
_format_documentation which calls minihtml which calls mdpopups.md2html.

@predragnikolic
Copy link
Member

Tested ✔️

@rchl
Copy link
Member Author

rchl commented Dec 21, 2022

Yep, I'm also confident that this is correct.

@rchl rchl merged commit 8da6bf7 into main Dec 21, 2022
@rchl rchl deleted the fix/doc-rendering branch December 21, 2022 20:36
rchl added a commit that referenced this pull request Jan 16, 2023
* main: (30 commits)
  Make Document Symbols behavior more consistent with built-in Goto Symbol (#2166)
  docs: fsautocomplete config - remove redundant argument (#2165)
  Allow missing window/workDoneProgress/create request from the server (#2159)
  Use "plaintext" language ID for plain text files (#2164)
  Improve type annotations (#2162)
  Don't use "escapeall" extension when formatting with mdpopups (#2163)
  Cut 1.21.0
  Fix inlay hint parts wrapping into multiple lines (#2153)
  Ensure commands triggered from minihtml run on correct view (#2154)
  Add "Source Action" entry to the "Edit" main menu (#2149)
  Add "Refactor" entry to the "Edit" main menu (#2141)
  fix completion documentation being parsed as markdown twice (#2146)
  when going to definition scroll to start of the region, not end (#2147)
  Auto-restart on server crashing, up to 5 times (#2145)
  improve performance of completion & signature request on typing (#2148)
  fix code lenses not updating after Undo (#2139)
  docs: fix mixed indentation in language servers configuration
  add missing Goto commands to Command Palette (#2140)
  docs: add missing keyboard shortcuts (#2143)
  Pass force_group to LocationPicker (#2134)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants