Skip to content

Commit

Permalink
Fix URI format for res scheme (#2432)
Browse files Browse the repository at this point in the history
Also fix exception for Find References
  • Loading branch information
jwortmann authored Mar 16, 2024
1 parent 983df8b commit d4538fa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def map_client_path_to_server_uri(self, path: str) -> str:

def map_server_uri_to_client_path(self, uri: str) -> str:
scheme, path = parse_uri(uri)
if scheme != "file":
if scheme not in ("file", "res"):
raise ValueError("{}: {} URI scheme is unsupported".format(uri, scheme))
if self.path_maps:
for path_map in self.path_maps:
Expand Down
2 changes: 1 addition & 1 deletion plugin/core/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _to_resource_uri(path: str, prefix: str) -> str:
See: https://github.com/sublimehq/sublime_text/issues/3742
"""
return "res://Packages{}".format(pathname2url(path[len(prefix):]))
return "res:/Packages{}".format(pathname2url(path[len(prefix):]))


def _uppercase_driveletter(match: Any) -> str:
Expand Down
2 changes: 1 addition & 1 deletion plugin/locationpicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def open_basic_file(
if uri.startswith("file:"):
filename = session.config.map_server_uri_to_client_path(uri)
else:
prefix = 'res://Packages' # Note: keep in sync with core/url.py#_to_resource_uri
prefix = 'res:/Packages' # Note: keep in sync with core/url.py#_to_resource_uri
assert uri.startswith(prefix)
filename = sublime.packages_path() + url2pathname(uri[len(prefix):])
# Window.open_file can only focus and scroll to a location in a resource file if it is already opened
Expand Down
2 changes: 1 addition & 1 deletion tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MultiplatformTests(unittest.TestCase):

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

def test_buffer_uri(self):
view = sublime.active_window().active_view()
Expand Down

0 comments on commit d4538fa

Please sign in to comment.