diff --git a/common/content/buffer.js b/common/content/buffer.js index cc2f1eae..9a542a7d 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -375,7 +375,7 @@ var Buffer = Module("buffer", { * @returns {string} */ get currentWord() Buffer.currentWord(this.focusedFrame), - getCurrentWord: deprecated("buffer.currentWord", function getCurrentWord() this.currentWord), + getCurrentWord: deprecated("buffer.currentWord", function getCurrentWord() Buffer.currentWord(this.focusedFrame, true)), /** * Returns true if a scripts are allowed to focus the given input @@ -1088,7 +1088,7 @@ var Buffer = Module("buffer", { * * @returns {string} */ - currentWord: function currentWord(win) { + currentWord: function currentWord(win, select) { let selection = win.getSelection(); if (selection.rangeCount == 0) return ""; @@ -1099,6 +1099,10 @@ var Buffer = Module("buffer", { Editor.extendRange(range, true, re, true); Editor.extendRange(range, false, re, true); } + if (select) { + selection.removeAllRanges(); + selection.addRange(range); + } return util.domToString(range); }, diff --git a/common/modules/finder.jsm b/common/modules/finder.jsm index 54ea364c..a2aeb145 100644 --- a/common/modules/finder.jsm +++ b/common/modules/finder.jsm @@ -41,10 +41,13 @@ var RangeFinder = Module("rangefinder", { if (this.rangeFind && equals(this.rangeFind.window.get(), this.window)) this.rangeFind.reset(); - this.find("", mode === this.modes.FIND_BACKWARD); + this.find("", mode == this.modes.FIND_BACKWARD); }, bootstrap: function (str, backward) { + if (arguments.length < 2 && this.rangeFind) + backward = this.rangeFind.reverse; + let highlighted = this.rangeFind && this.rangeFind.highlighted; let selections = this.rangeFind && this.rangeFind.selections; let linksOnly = false; @@ -209,7 +212,7 @@ var RangeFinder = Module("rangefinder", { }); }, mappings: function (dactyl, modules, window) { - const { buffer, config, mappings, modes, rangefinder } = modules; + const { Buffer, buffer, config, mappings, modes, rangefinder } = modules; var myModes = config.browserModes.concat([modes.CARET]); mappings.add(myModes, @@ -231,14 +234,14 @@ var RangeFinder = Module("rangefinder", { mappings.add(myModes.concat([modes.CARET, modes.TEXT_EDIT]), ["*"], "Find word under cursor", function () { - rangefinder.find(buffer.getCurrentWord(), false); + rangefinder.find(Buffer.currentWord(buffer.focusedFrame, true), false); rangefinder.findAgain(); }); mappings.add(myModes.concat([modes.CARET, modes.TEXT_EDIT]), ["#"], "Find word under cursor backwards", function () { - rangefinder.find(buffer.getCurrentWord(), true); + rangefinder.find(Buffer.currentWord(buffer.focusedFrame, true), true); rangefinder.findAgain(); });