Skip to content

Commit 329563a

Browse files
authored
Merge pull request #137 from risingphoenix/master
import namespace: correct paths on windows systems
2 parents 85f69d0 + 5ede58f commit 329563a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

php_companion/commands/import_namespace_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ImportNamespaceCommand(sublime_plugin.TextCommand):
1111
def run(self, edit):
1212
projectPath = get_active_project_path()
1313
file_name = self.view.file_name().replace(projectPath, '')
14-
if file_name.startswith('/'):
14+
if file_name.startswith('/') or file_name.startswith('\\'):
1515
file_name = file_name[1:]
1616

1717
# Abort if the file is not PHP

php_companion/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,19 @@ def get_composer():
8383
def get_namespace(filename):
8484
data = get_composer()
8585
for _replace_with, _path in data['autoload']['psr-4'].items():
86+
_path = normalize_to_system_style_path(_path)
8687
if _path.startswith('./'):
87-
_path = _path[2:]
88+
_path = _path[2:]
8889

8990
if filename.startswith(_path):
9091
namespace = filename.replace(_path, _replace_with)
9192
namespace = re.sub('/', '\\\\', namespace)
9293
return namespace.strip("\\").replace('\\\\', '\\')
9394

9495
for _replace_with, _path in data['autoload-dev']['psr-4'].items():
96+
_path = normalize_to_system_style_path(_path)
9597
if _path.startswith('./'):
96-
_path = _path[2:]
98+
_path = _path[2:]
9799

98100
if filename.startswith(_path):
99101
namespace = filename.replace(_path, _replace_with)

0 commit comments

Comments
 (0)