@Override public int previousTab(int position) { int tabStop = 0; // Search for the first tab stop before the given position... SortedSet<Integer> headSet = myTabStops.headSet(Integer.valueOf(position)); if (!headSet.isEmpty()) { tabStop = headSet.last(); } // Don't go beyond the start of the line... return Math.max(0, tabStop); }