'Remove suffix from current line (there should not be any selection)'

def remove_suffix(self, suffix):

    cursor = self.textCursor()
    cursor.setPosition((cursor.position() - len(suffix)), QTextCursor.KeepAnchor)
    if (to_text_string(cursor.selectedText()) == suffix):
        cursor.removeSelectedText()
