protected boolean historySearchBackward() { if (historyBuffer == null || buf.length() == 0 || !buf.toString().equals(history.current())) { historyBuffer = buf.copy(); searchBuffer = getFirstWord(); } int searchIndex = searchBackwards(searchBuffer.toString(), history.index(), true); if (searchIndex == -1) { return false; } else { // Maintain cursor position while searching. if (history.moveTo(searchIndex)) { setBuffer(history.current()); } else { return false; } } return true; }
if (history.moveTo(searchIndex)) { setBuffer(history.current()); } else {
protected boolean viRepeatSearch() { if (searchDir == 0) { return false; } int si = searchDir < 0 ? searchBackwards(searchString, searchIndex, false) : searchForwards(searchString, searchIndex, false); if (si == -1 || si == history.index()) { return false; } searchIndex = si; /* * Show the match. */ buf.clear(); history.moveTo(searchIndex); buf.write(history.get(searchIndex)); if (VICMD.equals(keyMap)) { buf.move(-1); } return true; }
history.moveTo(searchIndex);