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