Skip to content

Commit c98ac78

Browse files
committed
handle non-text file views/sheets
also fix super is_visible calls ::facepalm::
1 parent 3bf0c05 commit c98ac78

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

SideBar.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,18 @@ def get_path(self, paths=[], context="", group=-1, index=-1):
4646
try:
4747
return paths[0]
4848
except IndexError:
49-
v = self.get_view(context, group, index)
50-
return v.file_name()
49+
return self.file_via_window(context, group, index)
5150

52-
def get_view(self, context='', group=-1, index=-1):
51+
def file_via_window(self, context='', group=-1, index=-1):
5352
w = self.window
5453
if context == 'tab':
55-
vig = w.views_in_group(group)
56-
return vig[index]
57-
return w.active_view()
54+
try:
55+
vig = w.views_in_group(group)
56+
return vig[index].file_name()
57+
except IndexError:
58+
sig = w.sheets_in_group(group)
59+
return sig[index].file_name()
60+
return w.active_view().file_name()
5861

5962
def copy_to_clipboard_and_inform(self, paths=[]):
6063
sublime.set_clipboard('\n'.join(paths))
@@ -91,7 +94,7 @@ def is_visible(self, paths=[], context='', **kwargs):
9194
if context not in ['palette', 'tab']:
9295
if int(sublime.version()) >= 4158:
9396
return False
94-
return super().is_visible(paths=[], context='', **kwargs)
97+
return super().is_visible(paths, context, **kwargs)
9598

9699
def run(self, paths=[], **kwargs):
97100
paths = self.get_paths(paths, **kwargs)
@@ -107,7 +110,7 @@ def is_visible(self, paths=[], style='', **kwargs):
107110
return False
108111
if not get_setting(self, 'posix_copy_command'):
109112
return False
110-
return super().is_visible(paths=[], context='', **kwargs)
113+
return super().is_visible(paths, **kwargs)
111114

112115
def run(self, paths=[], style="", **kwargs):
113116
paths = self.get_paths(paths, **kwargs)
@@ -144,9 +147,11 @@ class SideBarDeleteCommand(SideBarCommand):
144147
def is_visible(self, paths=[], context='', **kwargs):
145148
# can only delete files that exist on disk
146149
for path in self.get_paths(paths, context, **kwargs):
150+
if path is None:
151+
return False
147152
if not os.path.exists(path):
148153
return False
149-
return super().is_visible(paths=[], context='', **kwargs)
154+
return super().is_visible(paths, context, **kwargs)
150155

151156
def run(self, paths=[], **kwargs):
152157
paths = self.get_paths(paths, **kwargs)

0 commit comments

Comments
 (0)