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 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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -656,23 +656,26 @@ def keyPressEvent(self, e):
t = unicode(e.text()) t = unicode(e.text())
## Close bracket automatically ## Close bracket automatically
if t in self.opening: if t in self.opening:
self.beginUndoAction()
i = self.opening.index(t) i = self.opening.index(t)
if self.hasSelectedText(): if self.hasSelectedText():
self.beginUndoAction()
selText = self.selectedText() selText = self.selectedText()
self.removeSelectedText() self.removeSelectedText()
if startLine == endLine: if startLine == endLine:
self.insert(self.opening[i] + selText + self.closing[i]) self.insert(self.opening[i] + selText + self.closing[i])
self.setCursorPosition(endLine, endPos+2) self.setCursorPosition(endLine, endPos+2)
self.endUndoAction()
return return
elif startLine < endLine and self.opening[i] in ("'", '"'): elif startLine < endLine and self.opening[i] in ("'", '"'):
self.insert("'''" + selText + "'''") self.insert("'''" + selText + "'''")
self.setCursorPosition(endLine, endPos+3)
self.endUndoAction()
return return
else: else:
self.insert(self.closing[i]) self.insert(self.closing[i])
self.endUndoAction()
else: else:
self.insert(self.closing[i]) self.insert(self.closing[i])
self.endUndoAction()
## FIXES #8392 (automatically removes the redundant char ## FIXES #8392 (automatically removes the redundant char
## when autoclosing brackets option is enabled) ## when autoclosing brackets option is enabled)
if t in [')', ']', '}']: if t in [')', ']', '}']:
Expand Down

0 comments on commit 28dbe74

Please sign in to comment.