Skip to content

Commit

Permalink
Fix cursor at end of line
Browse files Browse the repository at this point in the history
  • Loading branch information
bgallois committed Jun 9, 2020
1 parent 89114fb commit d992076
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spyder_vim/vim_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ def exit_visual_mode(self):
self._widget.update_vim_cursor()
self.visual_mode = False

def exit(self):
"""Exit insert mode."""
self.mode_changed.emit("normal")
editor = self._widget.editor()
cursor = self._editor_cursor()
editor.clear_extra_selections('vim_visual')
if cursor.atBlockEnd():
self._move_cursor(QTextCursor.Left)
self._widget.update_vim_cursor()

def search(self, key, reverse=False):
""""Search regular expressions key inside document"""
editor = self._widget.editor()
Expand Down Expand Up @@ -685,6 +695,7 @@ def o(self, repeat):
cursor.insertText("\n")
editor.setTextCursor(cursor)
editor.setFocus()
self._widget.update_vim_cursor()

def O(self, repeat):
"""Begin a new line above the cursor and insert text."""
Expand All @@ -695,6 +706,7 @@ def O(self, repeat):
cursor.movePosition(QTextCursor.Up)
editor.setTextCursor(cursor)
editor.setFocus()
self._widget.update_vim_cursor()

# %% Editing and cases(visual)
def u(self, repeat):
Expand Down Expand Up @@ -1053,6 +1065,7 @@ def focusInEvent(self, event):
QLineEdit.focusInEvent(self, event)
self.clear()
self.parent().on_mode_changed("normal")
self.parent().vim_keys.exit()

def focusOutEvent(self, event):
"""Enter editor mode."""
Expand Down

0 comments on commit d992076

Please sign in to comment.