Skip to content

Commit d4538fa

Browse files
authored
Fix URI format for res scheme (#2432)
Also fix exception for Find References
1 parent 983df8b commit d4538fa

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

plugin/core/types.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def map_client_path_to_server_uri(self, path: str) -> str:
855855

856856
def map_server_uri_to_client_path(self, uri: str) -> str:
857857
scheme, path = parse_uri(uri)
858-
if scheme != "file":
858+
if scheme not in ("file", "res"):
859859
raise ValueError("{}: {} URI scheme is unsupported".format(uri, scheme))
860860
if self.path_maps:
861861
for path_map in self.path_maps:

plugin/core/url.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _to_resource_uri(path: str, prefix: str) -> str:
8080
8181
See: https://github.com/sublimehq/sublime_text/issues/3742
8282
"""
83-
return "res://Packages{}".format(pathname2url(path[len(prefix):]))
83+
return "res:/Packages{}".format(pathname2url(path[len(prefix):]))
8484

8585

8686
def _uppercase_driveletter(match: Any) -> str:

plugin/locationpicker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def open_basic_file(
4747
if uri.startswith("file:"):
4848
filename = session.config.map_server_uri_to_client_path(uri)
4949
else:
50-
prefix = 'res://Packages' # Note: keep in sync with core/url.py#_to_resource_uri
50+
prefix = 'res:/Packages' # Note: keep in sync with core/url.py#_to_resource_uri
5151
assert uri.startswith(prefix)
5252
filename = sublime.packages_path() + url2pathname(uri[len(prefix):])
5353
# Window.open_file can only focus and scroll to a location in a resource file if it is already opened

tests/test_url.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class MultiplatformTests(unittest.TestCase):
6262

6363
def test_resource_path(self):
6464
uri = filename_to_uri(os.path.join(sublime.installed_packages_path(), "Package Control", "dir", "file.py"))
65-
self.assertEqual(uri, "res://Packages/Package%20Control/dir/file.py")
65+
self.assertEqual(uri, "res:/Packages/Package%20Control/dir/file.py")
6666

6767
def test_buffer_uri(self):
6868
view = sublime.active_window().active_view()

0 commit comments

Comments
 (0)