Skip to content

Commit

Permalink
remove settings from reset call, fix restart command
Browse files Browse the repository at this point in the history
  • Loading branch information
tomv564 committed Oct 29, 2015
1 parent f531149 commit 9c43b83
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 3 additions & 1 deletion application_commands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sublime_plugin
import sys, os
sys.path.append(os.path.dirname(os.path.realpath(__file__)))

from SublimeStackIDE.stack_ide_manager import StackIDEManager
from stack_ide_manager import StackIDEManager


class RestartStackIde(sublime_plugin.ApplicationCommand):
Expand Down
8 changes: 4 additions & 4 deletions stack_ide_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ def for_window(cls, window):

@classmethod
def kill_all(cls):
Log.normal("Killing all stack-ide-sublime instances:", {k:str(v) for k,v in StackIDEManager.ide_backend_instances.items()})
# Log.normal("Killing all stack-ide-sublime instances:", {k:str(v) for k, v in StackIDEManager.ide_backend_instances.items()})
for instance in StackIDEManager.ide_backend_instances.values():
print("yo")
instance.end()

@classmethod
def reset(cls, settings):
def reset(cls):
"""
Kill all instances, and forget about previous notifications.
"""
Log.normal("Resetting StackIDE")
cls.kill_all()
StackIDEManager.kill_all()
reset_complaints()
cls.settings = settings

@classmethod
def configure(cls, settings):
Expand Down
22 changes: 22 additions & 0 deletions test/test_stack_ide_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,28 @@ def test_retains_existing_instances(self):
self.assertEqual(1, len(StackIDEManager.ide_backend_instances))
sublime.destroy_windows()

def test_reset(self):
window = mock_window(['.'])
sublime.add_window(window)

StackIDEManager.check_windows()
self.assertEqual(1, len(StackIDEManager.ide_backend_instances))

# substitute a 'live' instance
backend = MagicMock()
stack_ide.stack_ide_loadtargets = Mock(return_value=['app/Main.hs', 'src/Lib.hs'])
instance = stack_ide.StackIDE(window, test_settings, backend)
StackIDEManager.ide_backend_instances[window.id()] = instance

StackIDEManager.reset()

# instances should be shut down.
self.assertEqual(1, len(StackIDEManager.ide_backend_instances))
self.assertFalse(instance.is_alive)
backend.send_request.assert_called_with(Req.get_shutdown())

sublime.destroy_windows()




Expand Down
5 changes: 3 additions & 2 deletions watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def plugin_loaded():
def plugin_unloaded():
global watchdog
watchdog.kill()
StackIDEManager.reset(settings)
StackIDEManager.reset()
watchdog = None


Expand All @@ -54,7 +54,8 @@ def on_settings_changed():
Log._set_verbosity(updated_settings.verbosity)
elif updated_settings.add_to_PATH != settings.add_to_PATH:
Log.normal("Settings changed, reloading backends")
StackIDEManager.reset(updated_settings)
StackIDEManager.configure(updated_settings)
StackIDEManager.reset()
elif updated_settings.show_popup != settings.show_popup:
Win.show_popup = updated_settings.show_popup

Expand Down

0 comments on commit 9c43b83

Please sign in to comment.