int (@NotNull Editor editor, @NotNull CaretStopPolicy caretStopPolicy, boolean isCamel, boolean handleQuoted) { int minOffset = getPreviousLineStopOffset(editor, caretStopPolicy.getLineStop()); final CaretStop wordStop = caretStopPolicy.getWordStop(); if (wordStop.equals(CaretStop.NONE)) return minOffset; final int offset = editor.getCaretModel().getOffset(); if (offset == minOffset) return minOffset; final CharSequence text = editor.getDocument().getCharsSequence(); final HighlighterIterator tokenIterator = createHighlighterIteratorAtOffset(editor, offset - 1); final int newOffset = getPreviousWordStopOffset(text, wordStop, tokenIterator, offset, minOffset, isCamel); if (newOffset > minOffset && handleQuoted && !tokenIterator.atEnd() && isTokenEnd(tokenIterator, newOffset + 1) && isQuotedToken(tokenIterator, text)) { // at the start of a closing quote: "word|" <- "word" | // find the end of an opening quote: "|word" <- "word|" (must be only a single step away) final int newOffsetAfterQuote = getPreviousWordStopOffset(text, CaretStop.BOTH, tokenIterator, newOffset, minOffset, isCamel); if (isTokenStart(tokenIterator, newOffsetAfterQuote - 1)) { return getPreviousWordStopOffset(text, wordStop, tokenIterator, newOffsetAfterQuote, minOffset, isCamel); // |"word" } } return newOffset; }