Skip to content

Commit

Permalink
Reintroduce "quiet" arg as "prefer_panel"
Browse files Browse the repository at this point in the history
Also rather implement `is_enabled` to maybe grey out the context menu.
  • Loading branch information
kaste committed Jun 29, 2020
1 parent 43f84aa commit 5417a63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Context.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
{
"id": "sublimelinter-fix",
"caption": "Quick Action",
"command": "sublime_linter_quick_actions"
"command": "sublime_linter_quick_actions",
"args": { "prefer_panel": true }
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
{
"caption": "SublimeLinter: Quick Action",
"command": "sublime_linter_quick_actions"
"command": "sublime_linter_quick_actions",
"args": { "prefer_panel": true }
},
{
"caption": "SublimeLinter: Reload SublimeLinter and its Plugins",
Expand Down
15 changes: 9 additions & 6 deletions quick_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@


class sublime_linter_quick_actions(sublime_plugin.TextCommand):
def is_visible(self, quiet=False):
# type: (bool) -> bool
return len(self.view.sel()) == 1
def is_enabled(self, prefer_panel=False, **kwargs):
# type: (bool, object) -> bool
if prefer_panel:
return len(self.view.sel()) == 1
else:
return True

def run(self, edit, quiet=False):
# type: (sublime.Edit, bool) -> None
def run(self, edit, prefer_panel=False, **kwargs):
# type: (sublime.Edit, bool, object) -> None
view = self.view
window = view.window()
assert window
Expand Down Expand Up @@ -61,7 +64,7 @@ def on_done(idx):
key=lambda action: (-len(action.solves), action.description)
)
if not actions:
if quiet:
if prefer_panel:
window.show_quick_panel(
["No quick action available."],
lambda x: None
Expand Down

0 comments on commit 5417a63

Please sign in to comment.