From 7c31eac960908f335f17e9004ad78c48e2bd6a4f Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Tue, 26 Apr 2022 23:20:51 +0100 Subject: [PATCH] lsp: Ensure labels with many ':' characters are handled --- lib/esbonio/changes/358.enhancement.rst | 1 - lib/esbonio/changes/359.enhancement.rst | 1 - lib/esbonio/changes/377.fix.rst | 1 + lib/esbonio/esbonio/lsp/sphinx/domains.py | 3 ++- .../tests/sphinx-default/test_sd_sphinx_domains.py | 4 ++-- lib/esbonio/tests/sphinx-default/workspace/code/cpp.rst | 8 ++++++++ .../tests/sphinx-default/workspace/definitions.rst | 2 ++ lib/esbonio/tests/sphinx-default/workspace/index.rst | 1 + 8 files changed, 16 insertions(+), 5 deletions(-) delete mode 100644 lib/esbonio/changes/358.enhancement.rst delete mode 100644 lib/esbonio/changes/359.enhancement.rst create mode 100644 lib/esbonio/changes/377.fix.rst create mode 100644 lib/esbonio/tests/sphinx-default/workspace/code/cpp.rst diff --git a/lib/esbonio/changes/358.enhancement.rst b/lib/esbonio/changes/358.enhancement.rst deleted file mode 100644 index 135f2c83f..000000000 --- a/lib/esbonio/changes/358.enhancement.rst +++ /dev/null @@ -1 +0,0 @@ -Language clients can now control if the server forces a full build of a Sphinx project on startup by providing a ``sphinx.forceFullBuild`` initialization option, which defaults to ``true`` diff --git a/lib/esbonio/changes/359.enhancement.rst b/lib/esbonio/changes/359.enhancement.rst deleted file mode 100644 index a7a6786de..000000000 --- a/lib/esbonio/changes/359.enhancement.rst +++ /dev/null @@ -1 +0,0 @@ -Language clients can now control the number of parallel jobs by providing a ``sphinx.numJobs`` initialization option, which defaults to ``auto``. Clients can disable parallel builds by setting this option to ``1`` diff --git a/lib/esbonio/changes/377.fix.rst b/lib/esbonio/changes/377.fix.rst new file mode 100644 index 000000000..169dc684a --- /dev/null +++ b/lib/esbonio/changes/377.fix.rst @@ -0,0 +1 @@ +``textDocument/documentLink`` requests no longer fail when encountering `::` characters in C++ references. diff --git a/lib/esbonio/esbonio/lsp/sphinx/domains.py b/lib/esbonio/esbonio/lsp/sphinx/domains.py index 9e2e21917..6ea802f4b 100644 --- a/lib/esbonio/esbonio/lsp/sphinx/domains.py +++ b/lib/esbonio/esbonio/lsp/sphinx/domains.py @@ -195,7 +195,8 @@ def resolve_intersphinx( if not self.rst.app: return None, None - project, label = label.split(":") + project, *parts = label.split(":") + label = ":".join(parts) targets = self.rst.get_intersphinx_targets(project, name, domain or "") for _, items in targets.items(): diff --git a/lib/esbonio/tests/sphinx-default/test_sd_sphinx_domains.py b/lib/esbonio/tests/sphinx-default/test_sd_sphinx_domains.py index 268e8842d..2a0377fff 100644 --- a/lib/esbonio/tests/sphinx-default/test_sd_sphinx_domains.py +++ b/lib/esbonio/tests/sphinx-default/test_sd_sphinx_domains.py @@ -278,8 +278,8 @@ async def test_role_target_completions(client: Client, text: str, setup): Location( uri="index.rst", range=Range( - start=Position(line=18, character=0), - end=Position(line=19, character=0), + start=Position(line=19, character=0), + end=Position(line=20, character=0), ), ), ), diff --git a/lib/esbonio/tests/sphinx-default/workspace/code/cpp.rst b/lib/esbonio/tests/sphinx-default/workspace/code/cpp.rst new file mode 100644 index 000000000..8f6644305 --- /dev/null +++ b/lib/esbonio/tests/sphinx-default/workspace/code/cpp.rst @@ -0,0 +1,8 @@ +C++ +=== + +.. cpp:class:: ExampleClass + + .. cpp:function:: bool isExample() + + This method indicates whether or not it is an example diff --git a/lib/esbonio/tests/sphinx-default/workspace/definitions.rst b/lib/esbonio/tests/sphinx-default/workspace/definitions.rst index 024eadaa2..187e74cc9 100644 --- a/lib/esbonio/tests/sphinx-default/workspace/definitions.rst +++ b/lib/esbonio/tests/sphinx-default/workspace/definitions.rst @@ -30,3 +30,5 @@ Some literal includes now This line refers to :ref:`setup-label` See the :doc:`/glossary` for details + +Find more info :cpp:func:`ExampleClass::isExample` diff --git a/lib/esbonio/tests/sphinx-default/workspace/index.rst b/lib/esbonio/tests/sphinx-default/workspace/index.rst index 2da220500..028699a64 100644 --- a/lib/esbonio/tests/sphinx-default/workspace/index.rst +++ b/lib/esbonio/tests/sphinx-default/workspace/index.rst @@ -12,6 +12,7 @@ Welcome to Defaults's documentation! :maxdepth: 2 :caption: Contents: + code/cpp theorems/index definitions glossary