code: def _makeMatchSelection(self, block, columnIndex, matched):
          
          selection = QTextEdit.ExtraSelection()
  
          if matched:
              bgColor = Qt.green
          else:
              bgColor = Qt.red
  
          selection.format.setBackground(bgColor)
          selection.cursor = QTextCursor(block)
          selection.cursor.setPosition(block.position() + columnIndex)
          selection.cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor)
  
          return selection
docs: Make matched or unmatched QTextEdit.ExtraSelection