Skip to content

Commit

Permalink
[pyqgis-console] fix undo/redo actions when autocompletion bracket is…
Browse files Browse the repository at this point in the history
… enabled
  • Loading branch information
slarosa committed Sep 9, 2013
1 parent 982960b commit 0aa9e03
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/console/console_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,23 +656,26 @@ def keyPressEvent(self, e):
t = unicode(e.text())
## Close bracket automatically
if t in self.opening:
self.beginUndoAction()
i = self.opening.index(t)
if self.hasSelectedText():
self.beginUndoAction()
selText = self.selectedText()
self.removeSelectedText()
if startLine == endLine:
self.insert(self.opening[i] + selText + self.closing[i])
self.setCursorPosition(endLine, endPos+2)
self.endUndoAction()
return
elif startLine < endLine and self.opening[i] in ("'", '"'):
self.insert("'''" + selText + "'''")
self.setCursorPosition(endLine, endPos+3)
self.endUndoAction()
return
else:
self.insert(self.closing[i])
self.endUndoAction()
else:
self.insert(self.closing[i])
self.endUndoAction()
## FIXES #8392 (automatically removes the redundant char
## when autoclosing brackets option is enabled)
if t in [')', ']', '}']:
Expand Down

0 comments on commit 0aa9e03

Please sign in to comment.