Skip to content

Commit f035ac0

Browse files
azizkprincemaple
authored andcommitted
Commands: added MixTestShowPanelCommand.
1 parent fb51bdf commit f035ac0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Use the default shortcut `Alt+Shift+F` or the palette command `Mix Format: File`
9191
- `Mix Test: Repeat`
9292
- `Mix Test: Set --seed`
9393
- `Mix Test: Toggle --stale Flag`
94+
- `Mix Test: Show Panel`
9495
- `Mix Format: File`
9596
- `Mix Format: Project / Folder`
9697
- `Mix Format: Toggle Auto-Formatting`

commands/Default.sublime-commands

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{ "caption": "Mix Test: Repeat", "command": "mix_test_repeat" },
1212
{ "caption": "Mix Test: Set --seed", "command": "mix_test_set_seed" },
1313
{ "caption": "Mix Test: Toggle --stale Flag", "command": "mix_test_toggle_stale_flag" },
14+
{ "caption": "Mix Test: Show Panel", "command": "mix_test_show_panel" },
1415
{ "caption": "Mix Format: File", "command": "mix_format_file" },
1516
{ "caption": "Mix Format: Project / Folder", "command": "mix_format_project" },
1617
{ "caption": "Mix Format: Toggle Auto-Formatting", "command": "mix_format_toggle_auto_format" },

commands/mix_test.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
# TODO: create a plugin test-suite: https://github.com/SublimeText/UnitTesting/
1616

17+
PANEL_NAME = 'output.mix_test'
18+
1719
class FILE_NAMES:
1820
SETTINGS_JSON = 'mix_test.settings.json'
1921
REPEAT_JSON = 'mix_test.repeat.json'
@@ -221,6 +223,16 @@ def run(self, **_kwargs):
221223
save_json_file(mix_settings_path, mix_params)
222224
print_status_msg('%s mix test --stale flag!' % ['Added', 'Removed'][has_stale_flag])
223225

226+
class MixTestShowPanelCommand(sublime_plugin.WindowCommand):
227+
def description(self):
228+
return 'Shows the output panel if existent and hidden.'
229+
230+
def run(self, **_kwargs):
231+
self.window.run_command('show_panel', {'panel': PANEL_NAME})
232+
233+
def is_enabled(self):
234+
return PANEL_NAME in self.window.panels()
235+
224236

225237
# Helper functions:
226238
##
@@ -450,7 +462,7 @@ def write_to_output(window, cmd_args, params, cwd, get_setting):
450462
output_view.set_scratch(True)
451463
elif mix_test_output == 'panel':
452464
output_view = window.create_output_panel('mix_test')
453-
window.run_command('show_panel', {'panel': 'output.mix_test'})
465+
window.run_command('show_panel', {'panel': PANEL_NAME})
454466
elif mix_test_output.startswith('file://'):
455467
mode = get_setting('output_mode') or 'w'
456468
output_path = mix_test_output[7:]

0 commit comments

Comments
 (0)