TextMateLexerState (@NotNull TextMateLexerState oldState, @NotNull TextMateLexerState newState) { if (!newState.matchData.matched()) { return oldState; } else if (!oldState.matchData.matched()) { return newState; } int newScore = newState.matchData.byteOffset().start; int oldScore = oldState.matchData.byteOffset().start; if (newScore < oldScore || newScore == oldScore && newState.priorityMatch.compareTo(oldState.priorityMatch) > 0) { if (!newState.matchData.byteOffset().isEmpty() || oldState.matchData.byteOffset().isEmpty() || hasBeginKey(newState)) { return newState; } } return oldState; }