From 7ace135ebb5fa8352958d232f7e039aadafea348 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sun, 5 Apr 2009 12:58:10 +0100 Subject: [PATCH] Make */# more robust. Will now always go to the next match instead of sometimes skipping and sometimes staying in the same place. --- common/content/find.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/content/find.js b/common/content/find.js index b354b343..bb764b77 100644 --- a/common/content/find.js +++ b/common/content/find.js @@ -316,8 +316,10 @@ function Search() //{{{ function () { found = false; - search.searchSubmitted(buffer.getCurrentWord(), false); - search.findAgain(); + let word = buffer.getCurrentWord(); + // A hacky way to move after the current match before searching forwards + window.content.getSelection().getRangeAt(0).collapse(false); + search.searchSubmitted(word, false) }); mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["#"], @@ -325,8 +327,10 @@ function Search() //{{{ function () { found = false; - search.searchSubmitted(buffer.getCurrentWord(), true); - search.findAgain(); + let word = buffer.getCurrentWord(); + // A hacky way to move before the current match before searching backwards + window.content.getSelection().getRangeAt(0).collapse(true); + search.searchSubmitted(word, true) }); /////////////////////////////////////////////////////////////////////////////}}} @@ -458,7 +462,7 @@ function Search() //{{{ backwards = forcedBackward; //Allow / to work. - if (!command) + if ((!command) || command == lastSearchPattern) return this.findAgain(backwards != lastSearchBackwards) this.clear();