diff -r 7a97c5817d0e -r 2424e64d384f QScintilla/Shell.py --- a/QScintilla/Shell.py Sun Jun 01 16:29:57 2014 +0200 +++ b/QScintilla/Shell.py Tue Jun 10 22:12:32 2014 +0200 @@ -725,8 +725,31 @@ """ Reimplemented slot to handle the paste action. """ - lines = QApplication.clipboard().text() - self.executeLines(lines) + if self.__isCursorOnLastLine(): + line, col = self.getCursorPosition() + lastLine = self.text(line) + + # Remove if text is selected + if self.hasSelectedText(): + lineFrom, indexFrom, lineTo, indexTo = self.getSelection() + if self.text(lineFrom).startswith(sys.ps1): + if indexFrom < len(sys.ps1): + indexFrom = len(sys.ps1) + elif self.text(lineFrom).startswith(sys.ps2): + if indexFrom < len(sys.ps2): + indexFrom = len(sys.ps2) + lastLine = lastLine[:indexFrom] + lastLine[indexTo:] + col = indexFrom + + self.setCursorPosition(line, 0) + self.deleteLineRight() + + lines = QApplication.clipboard().text() + lines = lastLine[:col] + lines + lastLine[col:] + self.executeLines(lines) + line, _ = self.getCursorPosition() + pos = len(self.text(line)) - (len(lastLine) - col) + self.setCursorPosition(line, pos) def __middleMouseButton(self): """ @@ -752,8 +775,15 @@ else: fullline = False + self.incrementalSearchActive = True self.__insertTextAtEnd(line) if fullline: + self.incrementalSearchActive = False + if cmd.startswith(sys.ps1): + cmd = cmd[len(sys.ps1):] + elif cmd.startswith(sys.ps2): + cmd = cmd[len(sys.ps2):] + self.__executeCommand(cmd) if self.interruptCommandExecution: self.__executeCommand("") @@ -792,7 +822,7 @@ line, col = self.__getEndPos() self.setCursorPosition(line, col) self.insert(s) - self.prline, self.prcol = self.getCursorPosition() + self.prline, _ = self.getCursorPosition() def __insertTextNoEcho(self, s): """