Skip to content
Open
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
40 changes: 22 additions & 18 deletions xdebug/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_real_path(uri, server=False):
try:
# scheme:///path/file => scheme, /path/file
# scheme:///C:/path/file => scheme, C:/path/file
transport, filename = uri.split(':///', 1)
transport, filename = uri.split(':///', 1)
except:
filename = uri

Expand All @@ -59,23 +59,27 @@ def get_real_path(uri, server=False):
if not drive_pattern.match(uri) and not os.path.isabs(uri):
uri = os.path.normpath('/' + uri)

mapped_paths = []
path_mapping = get_value(S.KEY_PATH_MAPPING)
if isinstance(path_mapping, dict):
# Go through path mappings
for server_path, local_path in path_mapping.items():
server_path = os.path.normpath(server_path)
local_path = os.path.normpath(local_path)
# Replace path if mapping available
if server:
# Map local path to server path
if local_path in uri:
uri = uri.replace(local_path, server_path)
break
else:
# Map server path to local path
if server_path in uri:
uri = uri.replace(server_path, local_path)
break
if isinstance(path_mapping, list):
mapped_paths.extend(path_mapping)
elif isinstance(path_mapping, dict):
mapped_paths.extend(path_mapping.items())
# Go through path mappings
for server_path, local_path in mapped_paths:
server_path = os.path.normpath(server_path)
local_path = os.path.normpath(local_path)
# Replace path if mapping available
if server:
# Map local path to server path
if local_path in uri:
uri = uri.replace(local_path, server_path)
break
else:
# Map server path to local path
if server_path in uri:
uri = uri.replace(server_path, local_path)
break
else:
sublime.set_timeout(lambda: sublime.status_message("Xdebug: No path mapping defined, returning given path."), 100)

Expand Down Expand Up @@ -282,4 +286,4 @@ def save_breakpoint_data():
def save_watch_data():
data_path = os.path.join(sublime.packages_path(), 'User', S.FILE_WATCH_DATA)
with open(data_path, 'wb') as data:
data.write(H.data_write(json.dumps(S.WATCH)))
data.write(H.data_write(json.dumps(S.WATCH)))