1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 07:28:00 +01:00

Fix buffer.getCurrentWord when the selection is collapsed and the word has punctuation.

This commit is contained in:
Kris Maglione
2009-01-14 23:26:40 -05:00
parent df2443d67c
commit 0b682ef42b
3 changed files with 11 additions and 18 deletions

View File

@@ -985,6 +985,7 @@ function Buffer() //{{{
selController.wordMove(false, false);
selController.wordMove(true, true);
selController.setCaretEnabled(caretmode);
return String.match(selection, /\w*/)[0];
}
let range = selection.getRangeAt(0);
if (util.computedStyle(range.startContainer).whiteSpace == "pre"

View File

@@ -648,8 +648,9 @@ const liberator = (function () //{{{
triggerObserver: function (type)
{
let args = Array.slice(arguments, 1);
for (let [,fn] in Iterator(observers[type] || []))
fn.apply(null, Array.slice(arguments, 1));
fn.apply(null, args);
},
beep: function ()

View File

@@ -113,8 +113,7 @@ const modes = (function () //{{{
if (newMode == modes.NORMAL)
{
// disable caret mode when we want to switch to normal mode
let value = options.getPref("accessibility.browsewithcaret", false);
if (value)
if (options.getPref("accessibility.browsewithcaret"))
options.setPref("accessibility.browsewithcaret", false);
statusline.updateUrl();
@@ -171,7 +170,7 @@ const modes = (function () //{{{
// helper function to set both modes in one go
// if silent == true, you also need to take care of the mode handling changes yourself
set: function (mainMode, extendedMode, silent)
set: function (mainMode, extendedMode, silent, stack)
{
silent = (silent || main == mainMode && extended == extendedMode);
// if a main mode is set, the extended is always cleared
@@ -187,6 +186,7 @@ const modes = (function () //{{{
if (main != oldMain)
handleModeChange(oldMain, mainMode, oldExtended);
}
liberator.triggerObserver("modeChange", [oldMain, oldExtended], [main, extended], stack);
if (!silent)
this.show();
@@ -195,18 +195,19 @@ const modes = (function () //{{{
push: function (mainMode, extendedMode, silent)
{
modeStack.push([main, extended]);
this.set(mainMode, extendedMode, silent);
this.set(mainMode, extendedMode, silent, { push: modeStack[modeStack.length - 1] });
},
pop: function (silent)
{
let a = modeStack.pop();
if (a)
this.set(a[0], a[1], silent);
this.set(a[0], a[1], silent, { pop: a });
else
this.reset(silent);
},
// TODO: Deprecate this in favor of addMode? --Kris
setCustomMode: function (modestr, oneventfunc, stopfunc)
{
// TODO this.plugin[id]... ('id' maybe submode or what..)
@@ -247,19 +248,10 @@ const modes = (function () //{{{
set isReplaying(value) { isReplaying = value; this.show(); },
get main() main,
set main(value)
{
if (value != main)
handleModeChange(main, value);
main = value;
// setting the main mode always resets any extended mode
extended = modes.NONE;
this.show();
},
set main(value) { this.set(value); },
get extended() extended,
set extended(value) { extended = value; this.show(); }
set extended(value) { this.set(null, value) }
};
@@ -286,7 +278,6 @@ const modes = (function () //{{{
self.addMode("SEARCH_BACKWARD", true);
self.addMode("MENU", true); // a popupmenu is active
self.addMode("LINE", true); // linewise visual mode
self.addMode("RECORDING", true);
self.addMode("PROMPT", true);
return self;