Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignoreFiles settings to avoid some files to be closed on timeout #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Files that were visited in the last minute will not be closed. (customize from s

- Close unrelated tabs to a user input directory.

- List of files that don't be closed (ignoreFiles list)

##Installation
### Now available through [Package Control](http://wbond.net/sublime_packages/package_control)!
The easiest method is through [Package Control](http://wbond.net/sublime_packages/package_control). Open the command palette with <kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>P</kbd> (Windows/Linux) or <kbd>⌘</kbd><kbd>Shift</kbd><kbd>P</kbd> (OSX) and type `pci` or `packconin` or whatever you like to get `Package Control: Install` showing. Click or hit <kbd>Enter</kbd>, type in `less` or `less tabs` ... and then hit <kbd>Enter</kbd>.
Expand Down
11 changes: 11 additions & 0 deletions lessTabs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import sublime, sublime_plugin, os, time, re

def is_ignored(path, ignorePatterns):
if 0 == len(ignorePatterns):
return False
for pattern in ignorePatterns:
if path and re.search(pattern, path) is not None:
return True
return False

class WM:
def get_project_folder(window):
project_folders = []
Expand Down Expand Up @@ -45,6 +53,9 @@ def run(self):

for buffer in self.window.views():
path = buffer.file_name()

if is_ignored(path, SETTINGS.get('ignoreFiles')):
continue

if (
buffer != active_view
Expand Down
5 changes: 4 additions & 1 deletion lessTabs.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"accessed_life_span": 60,

// If true the command of closing tabs will be executed when a new tab is opened
"close_on_open_new" : false
"close_on_open_new" : false,

// List of patterns for files that won't be closed on their time is come
"ignoreFiles": [],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using snake case to keep the same coding style

}