docs: def duplicate_line(self):
          """
          Duplicates the line under the cursor. If multiple lines are selected,
          only the last one is duplicated.
          """
          cursor = self.textCursor()
          assert isinstance(cursor, QtGui.QTextCursor)
          has_selection = True
          if not cursor.hasSelection():
              cursor.select(cursor.LineUnderCursor)
              has_selection = False
          line = cursor.selectedText()
          line = '\n'.join(line.split('\u2029'))
          end = cursor.selectionEnd()
          cursor.setPosition(end)
          cursor.beginEditBlock()
          cursor.insertText('\n')
          cursor.insertText(line)
          cursor.endEditBlock()
          if has_selection:
              pos = cursor.position()
              cursor.setPosition(end + 1)
              cursor.setPosition(pos, cursor.KeepAnchor)
          self.setTextCursor(cursor)