From c3ce38db9c47d2723648f5150c0641d058579538 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 31 Oct 2008 08:22:05 +0000 Subject: [PATCH] add note to buffer.getCurrentWord regarding Firefox's getSelection() bug --- content/buffer.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/content/buffer.js b/content/buffer.js index 8d53b7a2..b814f6e8 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -1272,21 +1272,23 @@ function Buffer() //{{{ }, // in contrast to vim, returns the selection if one is made, - // otherwise tries to guess the current word unter the text cursor + // otherwise tries to guess the current word under the text cursor // NOTE: might change the selection + // FIXME: getSelection() doesn't always preserve line endings, see: + // https://www.mozdev.org/bugs/show_bug.cgi?id=19303 getCurrentWord: function () { - var selection = window.content.getSelection().toString(); + let selection = window.content.getSelection().toString(); if (!selection) { - let selController = this.selectionController; - let caretmode = selController.getCaretEnabled(); - selController.setCaretEnabled(true); - selController.wordMove(false, false); - selController.wordMove(true, true); + let controller = this.selectionController; + let caretmode = controller.getCaretEnabled(); + controller.setCaretEnabled(true); + controller.wordMove(false, false); + controller.wordMove(true, true); selection = window.content.getSelection().toString(); - selController.setCaretEnabled(caretmode); + controller.setCaretEnabled(caretmode); } return selection;