Skip to content

Commit

Permalink
properly handle context arg fixes #50
Browse files Browse the repository at this point in the history
  • Loading branch information
braver committed Oct 26, 2023
1 parent 7252853 commit 0bd86ba
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions SideBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def is_visible(self, paths=[]):

class SideBarCopyNameCommand(MultipleFilesMixin, SideBarCommand):

def run(self, paths=[]):
def run(self, paths=[], context=""):
names = (os.path.split(path)[1] for path in self.get_paths(paths))
self.copy_to_clipboard_and_inform('\n'.join(names))

Expand All @@ -99,12 +99,12 @@ class SideBarCopyAbsolutePathCommand(MultipleFilesMixin, SideBarCommand):

def is_visible(self, paths=[], context=""):
# in 4158 ST gets the "copy path" sidebar context entry
# we want to keep our command palette entry though
if context != 'palette' and int(sublime.version()) >= 4158:
return False
return super().is_visible(paths, context)
# we want to keep our command palette and tab context entries though
if context in ['palette', 'tab']:
return super().is_visible(paths)
return int(sublime.version()) < 4158

def run(self, paths=[]):
def run(self, paths=[], context=""):
paths = self.get_paths(paths)
self.copy_to_clipboard_and_inform('\n'.join(paths))

Expand All @@ -114,7 +114,7 @@ def description(self):

class SideBarCopyRelativePathCommand(MultipleFilesMixin, SideBarCommand):

def run(self, paths=[]):
def run(self, paths=[], context=""):
paths = self.get_paths(paths)
root_paths = self.window.folders()
relative_paths = []
Expand All @@ -140,7 +140,7 @@ def description(self):

class SideBarDuplicateCommand(SideBarCommand):

def run(self, paths):
def run(self, paths, context=""):
source = self.get_path(paths)
base, leaf = os.path.split(source)

Expand Down Expand Up @@ -197,7 +197,7 @@ def description(self):

class SideBarMoveCommand(SideBarCommand):

def run(self, paths):
def run(self, paths, context=""):
source = self.get_path(paths)

input_panel = self.window.show_input_panel(
Expand Down Expand Up @@ -293,7 +293,7 @@ def on_post_window_command(self, window, command_name, args):
class SideBarNewCommand(SideBarCommand):
NEW_FILENAME = 'New file.txt'

def run(self, paths):
def run(self, paths, context=""):
source = self.get_path(paths)
select_extension = False

Expand Down

0 comments on commit 0bd86ba

Please sign in to comment.