angular-ui / AngularJS-sublime-package

AngularJS code completion, snippets, go to definition, quick panel search, and more.
MIT License
1.42k stars 169 forks source link

Windows / Indexing issues #6

Closed Narretz closed 11 years ago

Narretz commented 11 years ago

Hi,

I run Win 7 64bit / ST3 2032, and there is a problem while indexing the definitions:

walk_dirs does not parse excluded directories correctly. In walk_dirs, in this line, you have a unix style slash:

if not [skip for skip in self.kwargs['exclude_dirs'] if path + '/' + skip in r]:

It tries to index all it finds in node_modules, and then fails because it cannot find the first .js file it finds:

Exception in thread Thread-7:
Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "C:\...\AngularJS-sublime-package\AngularJS-sublime-package.py", line 347, in run
    self.walk_dirs()
  File "C:\...\AngularJS-sublime-package\AngularJS-sublime-package.py", line 370, in walk_dirs
    self.parse_file(_file, r, match_expressions)
  File "C:\...\AngularJS-sublime-package\AngularJS-sublime-package.py", line 405, in parse_file
    _file = codecs.open(r+'/'+file_path)
  File "X/codecs.py", line 884, in open
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\PROJECT_ROOT\\node_modules\\generator-angular\\node_modules\\yeoman-generator\\node_modules\\bower\\node_modules\\request\\node_modules\\form-data\\node_modules\\combined-stream\\node_modules\\delayed-stream\\test\\integration/test-delayed-http-upload.js'

Note that the last slash before the file is a unix-style slash, while all others are correct. This is a problem in parse_file, because it does:

_file = codecs.open(r+'/'+file_path)

So it's two bugs, with one common cause: exclude_dirs is ignored by walk_dirs Windows slashes are ignored parse_file

because of unix / win path separator mismatch

Additionally, I get the same exception when a value in exclude_dirs has a trailing slash at the end, as in the default "node_modules/"

Sorry I repeated myself so often, I tracked this down iteratively

I solved these issues by using os.sep and os.path.normpath. Not sure if this is the best way, might create a pull request later

subhaze commented 11 years ago

Man... I meant to change that awhile back, thanks for reporting man!

I've been slammed with work from my day job the past couple weeks but i'll try to knock out an update this evening or tomorrow evening.