Skip to content

Commit

Permalink
Fix multi-line paste in usdview's interpreter
Browse files Browse the repository at this point in the history
Fixes #1117

(Internal change: 2052058)
  • Loading branch information
sunyab authored and pixar-oss committed Mar 31, 2020
1 parent 2522789 commit 811565f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pxr/usdImaging/usdviewq/pythonInterpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,21 @@ def dragLeaveEvent(self, e):
def insertFromMimeData(self, source):
if not self._CursorIsInInputArea():
self._MoveCursorToEndOfInput()
super(View, self).insertFromMimeData(source)

if source.hasText():
text = source.text().replace('\r', '')
textLines = text.split('\n')
if (textLines[-1] == ''):
textLines = textLines[:-1]
for i in range(len(textLines)):
line = textLines[i]
cursor = self.textCursor()
cursor.movePosition(QtGui.QTextCursor.End)
cursor.insertText(line)
cursor.movePosition(QtGui.QTextCursor.End)
self.setTextCursor(cursor)
if i < len(textLines) - 1:
self.returnPressed.emit()

def keyPressEvent(self, e):
"""
Expand Down

0 comments on commit 811565f

Please sign in to comment.