From 20c5d3b2ef15833d6f01eefc5b2b2a89736c1538 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 20 Jan 2021 20:48:42 +0100 Subject: LanguageServer: quote URI, adjust lsp.py (for Windows) URI on windows have the colon character (':') quoted. --- pyGHDL/lsp/lsp.py | 3 +-- testsuite/pyunit/lsp/LanguageServer.py | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyGHDL/lsp/lsp.py b/pyGHDL/lsp/lsp.py index 1806db8d8..7d869d484 100644 --- a/pyGHDL/lsp/lsp.py +++ b/pyGHDL/lsp/lsp.py @@ -47,8 +47,7 @@ def path_from_uri(uri): def path_to_uri(path): # Convert path to file uri (add html like head part) if is_windows: - # Do not quote ':' (nor '/'). - return "file:///" + quote(path.replace("\\", "/"), "/:") + return "file:///" + quote(path.replace("\\", "/")) else: return "file://" + quote(path) diff --git a/testsuite/pyunit/lsp/LanguageServer.py b/testsuite/pyunit/lsp/LanguageServer.py index 2ef378b9a..39d23184e 100644 --- a/testsuite/pyunit/lsp/LanguageServer.py +++ b/testsuite/pyunit/lsp/LanguageServer.py @@ -4,6 +4,7 @@ from sys import executable from io import BytesIO from json import load as json_load, loads as json_loads, dumps as json_dumps from pathlib import Path +from urllib.parse import quote from subprocess import run as subprocess_run, PIPE from typing import Optional from unittest import TestCase, skip @@ -69,7 +70,7 @@ def root_subst(obj, root): if k in ('rootUri', 'uri'): assert v.startswith("file://@ROOT@/") p = "file://" + ("/" if is_windows else "") - obj[k] = p + root + v[13:] + obj[k] = p + quote(root + v[13:]) elif k in ('rootPath', 'message'): obj[k] = v.replace('@ROOT@', root) else: -- cgit v1.2.3