Skip to content

Commit

Permalink
Add auto folder render depth option (#166)
Browse files Browse the repository at this point in the history
Fixes #165

Makes the default `render_folder_depth` setting to be `auto`, which will render folders up to any open folders in the window.
  • Loading branch information
dbeckwith authored and jonathanrdelgado committed Oct 1, 2018
1 parent 1365807 commit 91a9fff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions TodoReview.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,16 @@ def draw_results(self):
def draw_file(self, item):
if settings.get('render_include_folder', False):
depth = settings.get('render_folder_depth', 1)
f = os.path.dirname(item['file']).replace('\\', '/').split('/')
f = '/'.join(f[-depth:] + [os.path.basename(item['file'])])
if depth == 'auto':
f = item['file']
for folder in sublime.active_window().folders():
if f.startswith(folder):
f = os.path.relpath(f, folder)
break
f = f.replace('\\', '/')
else:
f = os.path.dirname(item['file']).replace('\\', '/').split('/')
f = '/'.join(f[-depth:] + [os.path.basename(item['file'])])
else:
f = os.path.basename(item['file'])
return '%f:%l' \
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ Additionally, if you choose to include folders in your report, you may also spec
"render_folder_depth": 5
```

If you are using Sublime in a project or have folders open, you may find it helpful to set `"render_folder_depth"` to `"auto"`, which will render folders in the report up to any folders you have open. For example, if you're working on a project rooted at `/home/user/code/project`, and you have a TODO in `/home/user/code/project/src/file.cpp`, the report would render the file as `src/file.cpp`.

## Align results
TodoReview now automatically aligns the comments for you, calculating the largest result and aligning the rest accordingly. The system default for maximum spaces is `50`, which prevents a single file with an abnormally long length completely ruining your results. You can change this setting by editing `render_maxspaces`

Expand Down

0 comments on commit 91a9fff

Please sign in to comment.