Skip to content

Commit

Permalink
Prevent loosing cursor selection when showing context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDuquesnoy committed Sep 23, 2015
1 parent 747556a commit eced2ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyqode/core/api/code_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,10 @@ def get_context_menu(self):

def _show_context_menu(self, point):
""" Shows the context menu """
self.setTextCursor(self.cursorForPosition(point))
tc = self.textCursor()
nc = self.cursorForPosition(point)
if not nc.position() in range(tc.selectionStart(), tc.selectionEnd()):
self.setTextCursor(nc)
self._mnu = self.get_context_menu()
if len(self._mnu.actions()) > 1 and self.show_context_menu:
self._mnu.popup(self.mapToGlobal(point))
Expand Down

0 comments on commit eced2ce

Please sign in to comment.