Example #1
0
 def testAbortsIfAskedToNotResetDuringInit(self):
     self.state.action = 'foo'
     with mock.patch.object(Vintageous.state,
                            '_dont_reset_during_init') as x:
         x.return_value = True
         _init_vintageous(self.state.view)
         self.assertEqual(self.state.action, 'foo')
Example #2
0
 def run(self):
     v = self.window.active_view()
     v.settings().erase("vintage")
     _init_vintageous(v)
     DotFile.from_user().run()
     print("Package.Vintageous: State reset.")
     sublime.status_message("Vintageous: State reset")
Example #3
0
 def run(self):
     v = self.window.active_view()
     v.settings().erase('vintage')
     _init_vintageous(v)
     DotFile.from_user().run()
     print("Package.Vintageous: State reset.")
     sublime.status_message("Vintageous: State reset")
Example #4
0
 def on_activated(self, view):
     if self.timer:
         self.timer.cancel()
         # Switching to a different view; enter normal mode.
         _init_vintageous(view)
     else:
         # Switching back from another application. Ignore.
         pass
Example #5
0
 def on_activated(self, view):
     if self.timer:
         self.timer.cancel()
         # Switching to a different view; enter normal mode.
         _init_vintageous(view)
     else:
         # Switching back from another application. Ignore.
         pass
Example #6
0
 def on_load(self, view):
     # Without this, on OS X Vintageous might not initialize correctly if the user leaves
     # the application in a windowless state and then creates a new buffer.
     if sublime.platform() == 'osx':
         try:
             _init_vintageous(view)
         except AttributeError:
             _logger().error(
                 '[VintageStateTracker] .settings() missing during .on_load() for {0}'
                     .format(view.file_name()))
Example #7
0
 def on_load(self, view):
     # Without this, on OS X Vintageous might not initialize correctly if the user leaves
     # the application in a windowless state and then creates a new buffer.
     if sublime.platform() == 'osx':
         try:
             _init_vintageous(view)
         except AttributeError:
             _logger().error(
                 '[VintageStateTracker] .settings() missing during .on_load() for {0}'
                 .format(view.file_name()))
Example #8
0
 def testCallsEnterNormalModeCommandIfStateIsInVisualLineMode(self):
     self.state.mode = MODE_VISUAL_LINE
     with mock.patch.object(self.state.view, 'run_command') as m:
         _init_vintageous(self.state.view)
         m.assert_called_once_with('enter_normal_mode')
Example #9
0
 def testCallsEnterNormalModeFromInsertModeCommandIfStateIsInReplaceMode(
         self):
     self.state.mode = MODE_REPLACE
     with mock.patch.object(self.state.view, 'run_command') as m:
         _init_vintageous(self.state.view)
         m.assert_called_once_with('vi_enter_normal_mode_from_insert_mode')
Example #10
0
 def testResetIsCalled(self):
     self.state.action = 'foo'
     with mock.patch.object(VintageState, 'reset') as m:
         _init_vintageous(self.state.view)
         self.assertEqual(m.call_count, 1)
Example #11
0
 def testResets(self):
     self.state.action = 'foo'
     _init_vintageous(self.state.view)
     self.assertEqual(self.state.action, None)
Example #12
0
 def testResetIsCalled(self):
     self.state.action = 'foo'
     with mock.patch.object(VintageState, 'reset') as m:
         _init_vintageous(self.state.view)
         self.assertEqual(m.call_count, 1)
Example #13
0
 def on_new(self, view):
     # Without this, on OS X Vintageous might not initialize correctly if the user leaves
     # the application in a windowless state and then creates a new buffer.
     if sublime.platform() == 'osx':
         _init_vintageous(view)
Example #14
0
 def testAbortsIfPassedViewWithoutSettings(self):
     self.state.action = 'foo'
     _init_vintageous(object())
     self.assertEqual(self.state.action, 'foo')
Example #15
0
 def on_load(self, view):
     _init_vintageous(view)
Example #16
0
 def testCallsRunNormalInsertModeActionsCommandIfStateIsInNormalInsertMode(self):
     self.state.mode = MODE_NORMAL_INSERT
     with mock.patch.object(self.state.view, 'run_command') as m:
         _init_vintageous(self.state.view)
         m.assert_called_once_with('vi_run_normal_insert_mode_actions')
Example #17
0
 def run(self):
     v = self.window.active_view()
     v.settings().erase('vintage')
     _init_vintageous(v)
     print("Package.Vintageous: State reset.")
     sublime.status_message("Vintageous: State reset")
Example #18
0
 def testCallsEnterNormalModeFromInsertModeCommandIfStateIsInReplaceMode(self):
     self.state.mode = MODE_REPLACE
     with mock.patch.object(self.state.view, 'run_command') as m:
         _init_vintageous(self.state.view)
         m.assert_called_once_with('vi_enter_normal_mode_from_insert_mode')
Example #19
0
 def testCallsEnterNormalModeCommandIfStateIsInVisualLineMode(self):
     self.state.mode = MODE_VISUAL_LINE
     with mock.patch.object(self.state.view, 'run_command') as m:
         _init_vintageous(self.state.view)
         m.assert_called_once_with('enter_normal_mode')
Example #20
0
 def testResets(self):
     self.state.action = 'foo'
     _init_vintageous(self.state.view)
     self.assertEqual(self.state.action, None)
Example #21
0
 def testCallsRunNormalInsertModeActionsCommandIfStateIsInNormalInsertMode(
         self):
     self.state.mode = MODE_NORMAL_INSERT
     with mock.patch.object(self.state.view, 'run_command') as m:
         _init_vintageous(self.state.view)
         m.assert_called_once_with('vi_run_normal_insert_mode_actions')
Example #22
0
 def testAbortsIfPassedWidget(self):
     self.state.action = 'foo'
     self.state.view.settings().set('is_widget', True)
     _init_vintageous(self.state.view)
     self.assertEqual(self.state.action, 'foo')
Example #23
0
 def on_new(self, view):
     # Without this, on OS X Vintageous might not initialize correctly if
     # the user leaves the application in a windowless state and then
     # creates a new buffer.
     if sublime.platform() == 'osx':
         _init_vintageous(view)
Example #24
0
 def testAbortsIfPassedViewWithoutSettings(self):
     self.state.action = 'foo'
     _init_vintageous(object())
     self.assertEqual(self.state.action, 'foo')
Example #25
0
 def testAbortsIfPassedWidget(self):
     self.state.action = 'foo'
     self.state.view.settings().set('is_widget', True)
     _init_vintageous(self.state.view)
     self.assertEqual(self.state.action, 'foo')
Example #26
0
 def testAbortsIfAskedToNotResetDuringInit(self):
     self.state.action = 'foo'
     with mock.patch.object(Vintageous.state, '_dont_reset_during_init') as x:
         x.return_value = True
         _init_vintageous(self.state.view)
         self.assertEqual(self.state.action, 'foo')