Fixes #18526: Pasting data from clipboard inside Python console causes the text cursor to be moved to the end of the row

This commit is contained in:
Salvatore Larosa 2018-03-23 22:41:00 +01:00
parent bc45258b51
commit 3a5fb9d7bd

View File

@ -244,7 +244,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter):
def get_end_pos(self):
"""Return (line, index) position of the last character"""
line = self.lines() - 1
return (line, len(self.text(line)))
return line, len(self.text(line))
def is_cursor_at_end(self):
"""Return True if cursor is at the end of text"""
@ -560,8 +560,9 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter):
if pasteList[-1] != "":
line = pasteList[-1]
cleanLine = line.replace(">>> ", "").replace("... ", "")
curpos = self.getCursorPosition()
self.insert(cleanLine)
self.move_cursor_to_end()
self.setCursorPosition(curpos[0], curpos[1] + len(cleanLine))
def insertTextFromFile(self, listOpenFile):
for line in listOpenFile[:-1]: