mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-25 23:15:45 +01:00
Make <C-f>/<C-b> in caret mode not behave completely insanely.
This commit is contained in:
@@ -479,33 +479,26 @@ var Editor = Module("editor", {
|
|||||||
type: "operator"
|
type: "operator"
|
||||||
};
|
};
|
||||||
|
|
||||||
function caretExecute(arg, again) {
|
function caretExecute(arg) {
|
||||||
function fixSelection() {
|
let win = document.commandDispatcher.focusedWindow;
|
||||||
sel.removeAllRanges();
|
let controller = util.selectionController(win);
|
||||||
sel.addRange(RangeFind.endpoint(
|
|
||||||
RangeFind.nodeRange(buffer.focusedFrame.document.documentElement),
|
|
||||||
true));
|
|
||||||
}
|
|
||||||
|
|
||||||
let controller = util.selectionController(document.commandDispatcher.focusedWindow);
|
|
||||||
let sel = controller.getSelection(controller.SELECTION_NORMAL);
|
let sel = controller.getSelection(controller.SELECTION_NORMAL);
|
||||||
if (!sel.rangeCount) // Hack.
|
|
||||||
fixSelection();
|
|
||||||
|
|
||||||
try {
|
let buffer = Buffer(win);
|
||||||
|
if (!sel.rangeCount) // Hack.
|
||||||
|
buffer.resetCaret();
|
||||||
|
|
||||||
|
if (caretModeMethod == "pageMove") { // Grr.
|
||||||
|
buffer.scrollVertical("pages", caretModeArg ? 1 : -1);
|
||||||
|
buffer.resetCaret();
|
||||||
|
}
|
||||||
|
else
|
||||||
controller[caretModeMethod](caretModeArg, arg);
|
controller[caretModeMethod](caretModeArg, arg);
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
dactyl.assert(again && e.result === Cr.NS_ERROR_FAILURE);
|
|
||||||
fixSelection();
|
|
||||||
caretExecute(arg, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mappings.add([modes.VISUAL], keys, description,
|
mappings.add([modes.VISUAL], keys, description,
|
||||||
function ({ count }) {
|
function ({ count }) {
|
||||||
if (!count)
|
count = count || 1;
|
||||||
count = 1;
|
|
||||||
|
|
||||||
let caret = !dactyl.focusedElement;
|
let caret = !dactyl.focusedElement;
|
||||||
let editor_ = Editor.getEditor(null);
|
let editor_ = Editor.getEditor(null);
|
||||||
@@ -525,14 +518,13 @@ var Editor = Module("editor", {
|
|||||||
|
|
||||||
mappings.add([modes.CARET, modes.TEXT_EDIT, modes.OPERATOR], keys, description,
|
mappings.add([modes.CARET, modes.TEXT_EDIT, modes.OPERATOR], keys, description,
|
||||||
function ({ count }) {
|
function ({ count }) {
|
||||||
if (!count)
|
count = count || 1;
|
||||||
count = 1;
|
|
||||||
|
|
||||||
if (Editor.getEditor(null))
|
if (Editor.getEditor(null))
|
||||||
editor.executeCommand(textEditCommand, count);
|
editor.executeCommand(textEditCommand, count);
|
||||||
else {
|
else {
|
||||||
while (count--)
|
while (count--)
|
||||||
caretExecute(false, true);
|
caretExecute(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extraInfo);
|
extraInfo);
|
||||||
|
|||||||
@@ -505,9 +505,7 @@ var Buffer = Module("Buffer", {
|
|||||||
|
|
||||||
if (sel.rangeCount) {
|
if (sel.rangeCount) {
|
||||||
var range = sel.getRangeAt(0);
|
var range = sel.getRangeAt(0);
|
||||||
|
if (visible(range).height > 0)
|
||||||
let vis = visible(range);
|
|
||||||
if (vis.width > 0 && vis.height > 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var { rect } = DOM(range);
|
var { rect } = DOM(range);
|
||||||
|
|||||||
Reference in New Issue
Block a user