Ejemplo n.º 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')
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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()))
Ejemplo n.º 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()))
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 11
0
 def testResets(self):
     self.state.action = 'foo'
     _init_vintageous(self.state.view)
     self.assertEqual(self.state.action, None)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 14
0
 def testAbortsIfPassedViewWithoutSettings(self):
     self.state.action = 'foo'
     _init_vintageous(object())
     self.assertEqual(self.state.action, 'foo')
Ejemplo n.º 15
0
 def on_load(self, view):
     _init_vintageous(view)
Ejemplo n.º 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')
Ejemplo n.º 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")
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 20
0
 def testResets(self):
     self.state.action = 'foo'
     _init_vintageous(self.state.view)
     self.assertEqual(self.state.action, None)
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 24
0
 def testAbortsIfPassedViewWithoutSettings(self):
     self.state.action = 'foo'
     _init_vintageous(object())
     self.assertEqual(self.state.action, 'foo')
Ejemplo n.º 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')
Ejemplo n.º 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')