Skip to content

Commit

Permalink
[pyqgis-console] fix comment/uncomment code also on Windows OS
Browse files Browse the repository at this point in the history
  • Loading branch information
slarosa committed May 1, 2013
1 parent e11f4e8 commit 36e613a
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions python/console/console_editor.py
Expand Up @@ -389,32 +389,24 @@ def commentEditorCode(self, commentCheck):
if self.hasSelectedText():
startLine, _, endLine, _ = self.getSelection()
for line in range(startLine, endLine + 1):
selCmd = self.text(line)
self.setSelection(line, 0, line, selCmd.length())
self.removeSelectedText()
if commentCheck:
self.insert('#' + selCmd)
self.setCursorPosition(endLine, selCmd.length())
self.insertAt('#', line, 0)
else:
if selCmd.startsWith('#'):
self.insert(selCmd[1:])
else:
self.insert(selCmd)
self.setCursorPosition(endLine, self.text(line).length() - 1)
if not self.text(line).trimmed().startsWith('#'):
continue
self.setSelection(line, self.indentation(line),
line, self.indentation(line) + 1)
self.removeSelectedText()
else:
line, pos = self.getCursorPosition()
selCmd = self.text(line)
self.setSelection(line, 0, line, selCmd.length())
self.removeSelectedText()
if commentCheck:
self.insert('#' + selCmd)
self.setCursorPosition(line, selCmd.length())
self.insertAt('#', line, 0)
else:
if selCmd.startsWith('#'):
self.insert(selCmd[1:])
else:
self.insert(selCmd)
self.setCursorPosition(line, self.text(line).length() - 1)
if not self.text(line).trimmed().startsWith('#'):
return
self.setSelection(line, self.indentation(line),
line, self.indentation(line) + 1)
self.removeSelectedText()
self.endUndoAction()

def createTempFile(self):
Expand Down

0 comments on commit 36e613a

Please sign in to comment.