diff --git a/xdebug/util.py b/xdebug/util.py index 95badb0..efd035a 100644 --- a/xdebug/util.py +++ b/xdebug/util.py @@ -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 @@ -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) @@ -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))) \ No newline at end of file + data.write(H.data_write(json.dumps(S.WATCH)))