hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
295 stars 57 forks source link

Collection of mod_dirs in language_server.py does not work with relative paths #87

Closed mscfd closed 5 years ago

mscfd commented 5 years ago

Something like fortls --debug_rootpath src --debug_completion --debug_filepath src/some.f90 --debug_line 123 --debug_char 456

fails as subdirectories are not collected correctly. In fact in line 479 of langserver.py (tag 1.2.1) the os.path.join is wrong. As far as I can see local variable dirName is the relative path (relative to current working directory). If the provided path in --debug_rootpath is absolute, then dirName is also absolute and the os.path.join just returns its second argument (i.e. dirName). So a simple patch is to replace self.mod_dirs.append(os.path.join(self.root_path, dirName)) by self.mod_dirs.append(dirName)

But I guess a proper solution might involve something like normalising all involved paths.

hansec commented 5 years ago

Thanks for the report. Yep, the fix you suggested should work fine and will be included in the next patch.