Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add option menuitem to exclude "selected items" from the index (notes…

…: does not work with folders yet..)
  • Loading branch information...
commit 067db326b805163840333721cf2708d0e224e9fe 1 parent b038dc9
@titoBouzout authored
Showing with 42 additions and 3 deletions.
  1. +7 −2 Side Bar.sublime-menu
  2. +35 −1 SideBar.py
View
9 Side Bar.sublime-menu
@@ -107,11 +107,16 @@
{ "caption": "Edit Project", "id": "side-bar-project-open-file", "command": "side_bar_project_open_file", "args": {"paths": []} },
{ "caption": "Edit Preview URLs", "id": "side-bar-preview-edit-urls", "command": "side_bar_preview_edit_urls", "args": {"paths": []} },
{ "caption": "-", "id": "side-bar-project-open-file-separator" },
+ { "command": "prompt_add_folder", "caption": "Add Folder to Project…", "mnemonic": "d" },
+ { "caption": "-", "id": "side-bar-promote-as-project-folder-separator" },
{ "caption": "Promote as Project Folder", "id": "side-bar-project-item-add", "command": "side_bar_project_item_add", "args": {"paths": []} },
{ "caption": "Exclude From Project", "id": "side-bar-project-item-exclude", "command": "side_bar_project_item_exclude", "args": {"paths": []} },
{ "caption": "-", "id": "side-bar-project-item-separator" },
- { "caption": "Remove Folder from Project", "id": "side-bar-project-item-remove-folder", "command": "side_bar_project_item_remove_folder", "args": { "paths": []} },
- { "command": "prompt_add_folder", "caption": "Add Folder to Project…", "mnemonic": "d" }
+ { "id": "side-bar-project-item-exclude-from-index-item", "command": "side_bar_project_item_exclude_from_index", "args": {"paths": [], "type":"item"} },
+ { "id": "side-bar-project-item-exclude-from-index-file", "command": "side_bar_project_item_exclude_from_index", "args": {"paths": [], "type":"file"} },
+ { "id": "side-bar-project-item-exclude-from-index-extension", "command": "side_bar_project_item_exclude_from_index", "args": {"paths": [], "type":"extension"} },
+ { "caption": "-", "id": "side-bar-project-item-separator" },
+ { "caption": "Remove Folder from Project", "id": "side-bar-project-item-remove-folder", "command": "side_bar_project_item_remove_folder", "args": { "paths": []} }
]
},
View
36 SideBar.py
@@ -1274,7 +1274,7 @@ def run(self, paths = []):
project.add(item.path())
def is_enabled(self, paths = []):
- return SideBarSelection(paths).hasDirectories()
+ return SideBarSelection(paths).hasDirectories() and SideBarSelection(paths).hasProjectDirectories() == False
class SideBarProjectItemRemoveFolderCommand(sublime_plugin.WindowCommand):
def run(self, paths = []):
@@ -1297,6 +1297,40 @@ def run(self, paths = []):
def is_enabled(self, paths = []):
return SideBarSelection(paths).len() > 0 and SideBarSelection(paths).hasProjectDirectories() == False
+class SideBarProjectItemExcludeFromIndexCommand(sublime_plugin.WindowCommand):
+ def run(self, paths = [], type = 'item'):
+ Preferences = sublime.load_settings("Preferences.sublime-settings")
+ excluded = Preferences.get("index_exclude_patterns", [])
+ for item in self.items(paths, type):
+ excluded.append(item)
+ excluded = list(set(excluded))
+ Preferences.set("index_exclude_patterns", excluded);
+ sublime.save_settings("Preferences.sublime-settings");
+
+ def is_visible(self, paths = [], type = 'item'):
+ return len(self.items(paths, type)) > 0
+
+ def description(self, paths = [], type = 'item'):
+ items = self.items(paths, type)
+ return 'Exclude From the Index "'+(",".join(items))+'"'
+
+ def items(self, paths = [], type = 'item'):
+ items = []
+ if type == 'item':
+ for item in SideBarSelection(paths).getSelectedItems():
+ if item.isDirectory():
+ items.append(item.path()+'*')
+ else:
+ items.append(item.path())
+ elif type == 'extension':
+ for item in SideBarSelection(paths).getSelectedFiles():
+ items.append('*'+item.extension())
+ elif type == 'file':
+ for item in SideBarSelection(paths).getSelectedFiles():
+ items.append(item.name())
+ items = list(set(items))
+ return items
+
class SideBarDonateCommand(sublime_plugin.WindowCommand):
def run(self, paths = []):
import webbrowser
Please sign in to comment.
Something went wrong with that request. Please try again.