pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python-lsp/python-lsp-server/commit/5c8cfacbcd1ffe0bffa28df61a49d967222d255e

nk crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-94620c216484da1f.css" /> Copy `LAST_JEDI_COMPLETIONS` to cell document so that `completionItem… · python-lsp/python-lsp-server@5c8cfac · GitHub
Skip to content

Commit 5c8cfac

Browse files
authored
Copy LAST_JEDI_COMPLETIONS to cell document so that completionItem/resolve will work (#663)
1 parent 8c96441 commit 5c8cfac

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

pylsp/python_lsp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,12 @@ def _cell_document__completion(self, cellDocument, position=None, **_kwargs):
722722
if item.get("data", {}).get("doc_uri") == temp_uri:
723723
item["data"]["doc_uri"] = cellDocument.uri
724724

725+
# Copy LAST_JEDI_COMPLETIONS to cell document so that completionItem/resolve will work
726+
tempDocument = workspace.get_document(temp_uri)
727+
cellDocument.shared_data["LAST_JEDI_COMPLETIONS"] = (
728+
tempDocument.shared_data.get("LAST_JEDI_COMPLETIONS", None)
729+
)
730+
725731
return completions
726732

727733
def m_text_document__completion(self, textDocument=None, position=None, **_kwargs):

test/test_notebook_document.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,3 +530,71 @@ def test_notebook_completion(client_server_pair) -> None:
530530
},
531531
],
532532
}
533+
534+
535+
@pytest.mark.skipif(IS_WIN, reason="Flaky on Windows")
536+
def test_notebook_completion_resolve(client_server_pair) -> None:
537+
"""
538+
Tests that completion item resolve works correctly
539+
"""
540+
client, server = client_server_pair
541+
send_initialize_request(client)
542+
543+
# Open notebook
544+
with patch.object(server._endpoint, "notify") as mock_notify:
545+
send_notebook_did_open(
546+
client,
547+
[
548+
"def answer():\n\t'''Returns an important number.'''\n\treturn 42",
549+
"ans",
550+
],
551+
)
552+
# wait for expected diagnostics messages
553+
wait_for_condition(lambda: mock_notify.call_count >= 2)
554+
assert len(server.workspace.documents) == 3
555+
for uri in ["cell_1_uri", "cell_2_uri", "notebook_uri"]:
556+
assert uri in server.workspace.documents
557+
558+
future = client._endpoint.request(
559+
"textDocument/completion",
560+
{
561+
"textDocument": {
562+
"uri": "cell_2_uri",
563+
},
564+
"position": {"line": 0, "character": 3},
565+
},
566+
)
567+
result = future.result(CALL_TIMEOUT_IN_SECONDS)
568+
assert result == {
569+
"isIncomplete": False,
570+
"items": [
571+
{
572+
"data": {"doc_uri": "cell_2_uri"},
573+
"insertText": "answer",
574+
"kind": 3,
575+
"label": "answer()",
576+
"sortText": "aanswer",
577+
},
578+
],
579+
}
580+
581+
future = client._endpoint.request(
582+
"completionItem/resolve",
583+
{
584+
"data": {"doc_uri": "cell_2_uri"},
585+
"label": "answer()",
586+
},
587+
)
588+
result = future.result(CALL_TIMEOUT_IN_SECONDS)
589+
del result["detail"] # The value of this is unpredictable.
590+
assert result == {
591+
"data": {"doc_uri": "cell_2_uri"},
592+
"insertText": "answer",
593+
"kind": 3,
594+
"label": "answer()",
595+
"sortText": "aanswer",
596+
"documentation": {
597+
"kind": "markdown",
598+
"value": "```python\nanswer()\n```\n\n\nReturns an important number.",
599+
},
600+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy