private int getStartOfWordIndex(JTextComponent textComponent, int offset)
			throws BadLocationException {

		if (textComponent instanceof JPasswordField) {
			return 0;
		}

		Element currentParagraph = Utilities.getParagraphElement(textComponent, offset);
		int previousWordOffset = Utilities.getPreviousWord(textComponent, offset);
		boolean isInPreviousParagraph = previousWordOffset < currentParagraph.getStartOffset();
		if (isInPreviousParagraph) {
			Element previousParagraphElement =
				Utilities.getParagraphElement(textComponent, previousWordOffset);
			return previousParagraphElement.getEndOffset() - 1;
		}
		return previousWordOffset;
	}
An action to delete from the cursor position to the beginning of the current word, backwards.
Ghidra/Framework/Generic/src/main/java/generic/util/action/DeleteToStartOfWordAction.java