Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URI format for res scheme #2432

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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