mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 21:18:00 +01:00
Change buffer.getCurrentWord() to a read-only property buffer.currentWord.
This commit is contained in:
@@ -440,7 +440,7 @@ const Buffer = Module("buffer", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the currently selected word. If the selection is
|
* Returns the current selection. If the selection is
|
||||||
* null, it tries to guess the word that the caret is
|
* null, it tries to guess the word that the caret is
|
||||||
* positioned in.
|
* positioned in.
|
||||||
*
|
*
|
||||||
@@ -450,7 +450,9 @@ const Buffer = Module("buffer", {
|
|||||||
*/
|
*/
|
||||||
// FIXME: getSelection() doesn't always preserve line endings, see:
|
// FIXME: getSelection() doesn't always preserve line endings, see:
|
||||||
// https://www.mozdev.org/bugs/show_bug.cgi?id=19303
|
// https://www.mozdev.org/bugs/show_bug.cgi?id=19303
|
||||||
getCurrentWord: function () {
|
// FIXME: The ABRACADABRA nature of this function has always seemed bizarre
|
||||||
|
// to me. Who's with me? --djk
|
||||||
|
get currentWord() {
|
||||||
let win = tabs.localStore.focusedFrame || content;
|
let win = tabs.localStore.focusedFrame || content;
|
||||||
let selection = win.getSelection();
|
let selection = win.getSelection();
|
||||||
if (selection.rangeCount == 0)
|
if (selection.rangeCount == 0)
|
||||||
@@ -1568,7 +1570,7 @@ const Buffer = Module("buffer", {
|
|||||||
mappings.add(myModes, ["Y"],
|
mappings.add(myModes, ["Y"],
|
||||||
"Copy selected text or current word",
|
"Copy selected text or current word",
|
||||||
function () {
|
function () {
|
||||||
let sel = buffer.getCurrentWord();
|
let sel = buffer.currentWord;
|
||||||
dactyl.assert(sel);
|
dactyl.assert(sel);
|
||||||
dactyl.clipboardWrite(sel, true);
|
dactyl.clipboardWrite(sel, true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -664,7 +664,7 @@ const Editor = Module("editor", {
|
|||||||
modes.set(modes.TEXTAREA);
|
modes.set(modes.TEXTAREA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dactyl.clipboardWrite(buffer.getCurrentWord(), true);
|
dactyl.clipboardWrite(buffer.currentWord, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add([modes.VISUAL, modes.TEXTAREA],
|
mappings.add([modes.VISUAL, modes.TEXTAREA],
|
||||||
|
|||||||
@@ -195,14 +195,14 @@ const RangeFinder = Module("rangefinder", {
|
|||||||
"Find word under cursor",
|
"Find word under cursor",
|
||||||
function () {
|
function () {
|
||||||
rangefinder._found = false;
|
rangefinder._found = false;
|
||||||
rangefinder.onSubmit(buffer.getCurrentWord(), false);
|
rangefinder.onSubmit(buffer.currentWord, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["#"],
|
mappings.add(myModes.concat([modes.CARET, modes.TEXTAREA]), ["#"],
|
||||||
"Find word under cursor backwards",
|
"Find word under cursor backwards",
|
||||||
function () {
|
function () {
|
||||||
rangefinder._found = false;
|
rangefinder._found = false;
|
||||||
rangefinder.onSubmit(buffer.getCurrentWord(), true);
|
rangefinder.onSubmit(buffer.currentWord, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user