def _get_word_start_cursor(self, position):
        """ Find the start of the word to the left the given position. If a
            sequence of non-word characters precedes the first word, skip over
            them. (This emulates the behavior of bash, emacs, etc.)
        """
        document = self._control.document()
        cursor = self._control.textCursor()
        line_start_pos = self._get_line_start_pos()

        if position == self._prompt_pos:
            return cursor
        elif position == line_start_pos:
            # Cursor is at the beginning of a line, move to the last
            # non-whitespace character of the previous line
            cursor = self._control.textCursor()
            cursor.setPosition(position)
            cursor.movePosition(QtGui.QTextCursor.PreviousBlock)
            cursor.movePosition(QtGui.QTextCursor.EndOfBlock)
            position = cursor.position()
            while (
                position >= self._prompt_pos and
                is_whitespace(document.characterAt(position))
            ):
                position -= 1
            cursor.setPosition(position + 1)
        else:
            position -= 1

            # Find the last alphanumeric char, but don't move across lines
            while (
                position >= self._prompt_pos and
                position >= line_start_pos and
                not is_letter_or_number(document.characterAt(position))
            ):
                position -= 1

            # Find the first alphanumeric char, but don't move across lines
            while (
                position >= self._prompt_pos and
                position >= line_start_pos and
                is_letter_or_number(document.characterAt(position))
            ):
                position -= 1

            cursor.setPosition(position + 1)

        return cursor
 Find the start of the word to the left the given position. If a
            sequence of non-word characters precedes the first word, skip over
            them. (This emulates the behavior of bash, emacs, etc.)
        
angrmanagement/vendor/qtconsole/console_widget.py