Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
Plugin should work with project files outside actual project dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Jun 22, 2013
1 parent d845559 commit 90ccae4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tern.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def run(self, edit, **kw):

# resolve target file
if not os.path.isabs(target_file) and proj.get('id', 'empty') != 'empty':
target_file = os.path.join(os.path.dirname(proj['id']), target_file)
target_file = os.path.join(proj['dir'], target_file)
dfn['file'] = target_file

if target_file != file_name_from_view(view):
Expand Down
19 changes: 12 additions & 7 deletions ternjs/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_ternjs_files(project, config=None):
if config is None:
config = get_ternjs_config(project_path)

proj_dir = os.path.dirname(project_path)
proj_dir = config.get('dir', os.path.dirname(project_path))
fileset = FileSet(directory=proj_dir,
include=config.get('include', ['**/*.js']),
exclude=config.get('exclude', None))
Expand All @@ -106,11 +106,16 @@ def projects_from_opened_files(window=None):
result = set()
for wnd in windows:
for view in wnd.views():
f = view.file_name()
if f:
proj = locate_project(f, result)
if proj:
result.add(proj)
proj = None
if hasattr(view, 'project_file_name'):
# ST3 API: get project file from opened view
proj = view.project_file_name()
else:
f = view.file_name()
if f:
proj = locate_project(f, result)
if proj:
result.add(proj)

return list(result)

Expand All @@ -131,7 +136,7 @@ def info(project_id):
config = get_ternjs_config(project_id)
return {
'id': project_id,
'dir': os.path.dirname(project_id),
'dir': config.get('dir', os.path.dirname(project_id)),
'config': config,
'files': get_ternjs_files(project_id, config)
}
Expand Down

0 comments on commit 90ccae4

Please sign in to comment.