Skip to content

Commit d7e4ff5

Browse files
committed
fix and improve fm commands is_visible method
The logic use to be wrong with the menu_without_distraction (which honestly, no one should set to false anyway). It also now prints stuff to the console when it detects an internal error. I don't think this is the best way to report the error, but i don't want to nag the user with stupid pop ups, so i try to guess the best behavior when that happens.
1 parent 2b6aca9 commit d7e4ff5

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

FMcommands/appcommand.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@
66
class AppCommand(sublime_plugin.ApplicationCommand):
77
def is_visible(self, *args, **kwargs):
88
settings = get_settings()
9+
show = settings.get(
10+
"show_" + to_snake_case(type(self).__name__.replace("Fm", ""))
11+
)
12+
if show is None:
13+
# this should never happen, this is an error
14+
# we could nag the user to get him to report that issue,
15+
# but that's going to make this plugin really painful to use
16+
# So, I just print something to the console, and hope someone
17+
# sees and reports it
18+
print(
19+
"FileManager: No setting available for the command {!r}. This is an internal error, please report it".format(
20+
type(self).__name__
21+
)
22+
)
23+
show = True
24+
925
return bool(
10-
settings.get("show_" + to_snake_case(type(self).__name__.replace("Fm", "")))
26+
show
1127
and (
12-
self.is_enabled(*args, **kwargs)
13-
or not settings.get("menu_without_distraction")
28+
not settings.get("menu_without_distraction")
29+
or self.is_enabled(*args, **kwargs)
1430
)
1531
)

0 commit comments

Comments
 (0)