Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[pyqgis-console] fix undo/redo actions when autocompletion bracket is…
… enabled
  • Loading branch information
slarosa committed Sep 8, 2013
1 parent 214ef1d commit 28dbe74
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/console/console_editor.py
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 28dbe74

Please sign in to comment.