From 7fa0647e5364e6780e4643bfd0a6db29e200ce3d Mon Sep 17 00:00:00 2001 From: Michael Phang Date: Fri, 31 Jul 2015 12:58:15 -0400 Subject: [PATCH 1/2] Add Ability To Specify Ordered Path Mappings --- xdebug/util.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/xdebug/util.py b/xdebug/util.py index 95badb0..e05f8c5 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,28 @@ 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 = [] + ordered_path_mapping = get_value('ordered_path_mapping') path_mapping = get_value(S.KEY_PATH_MAPPING) + if isinstance(ordered_path_mapping, list): + mapped_paths.extend(ordered_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 + 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 +287,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))) From 7d5836a1d64397ff45e4c13d221b451b32186e37 Mon Sep 17 00:00:00 2001 From: Michael Phang Date: Fri, 23 Sep 2016 22:01:08 -0400 Subject: [PATCH 2/2] Removed Need For Extra Config Setting --- xdebug/util.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xdebug/util.py b/xdebug/util.py index e05f8c5..efd035a 100644 --- a/xdebug/util.py +++ b/xdebug/util.py @@ -60,11 +60,10 @@ def get_real_path(uri, server=False): uri = os.path.normpath('/' + uri) mapped_paths = [] - ordered_path_mapping = get_value('ordered_path_mapping') path_mapping = get_value(S.KEY_PATH_MAPPING) - if isinstance(ordered_path_mapping, list): - mapped_paths.extend(ordered_path_mapping) - if isinstance(path_mapping, dict): + 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: