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

Closes issue #449.

This commit is contained in:
Kris Maglione
2011-10-07 03:17:52 -04:00
parent 7028b8b84e
commit 40a23fc7cd
3 changed files with 34 additions and 26 deletions

View File

@@ -942,12 +942,9 @@ var CommandLine = Module("commandline", {
if (/^\s*$/.test(str)) if (/^\s*$/.test(str))
return; return;
this.store = this.store.filter(function (line) (line.value || line) != str); this.store = this.store.filter(function (line) (line.value || line) != str);
try { dactyl.trapErrors(function () {
this.store.push({ value: str, timestamp: Date.now()*1000, privateData: this.checkPrivate(str) }); this.store.push({ value: str, timestamp: Date.now()*1000, privateData: this.checkPrivate(str) });
} }, this);
catch (e) {
dactyl.reportError(e);
}
this.store = this.store.slice(-options["history"]); this.store = this.store.slice(-options["history"]);
}, },
/** /**

View File

@@ -514,7 +514,8 @@ var Buffer = Module("Buffer", {
rect = { x: rect.left, y: 0, width: rect.width, height: win.innerHeight }; rect = { x: rect.left, y: 0, width: rect.width, height: win.innerHeight };
} }
else { else {
rect = { x: win.innerWidth / 2, y: 0, width: 0, height: 0 }; let w = win.innerWidth;
rect = { x: w / 2 - w / 10, y: 0, width: w / 5, height: win.innerHeight };
} }
var reduce = function (a, b) DOM(a).rect.top < DOM(b).rect.top ? a : b; var reduce = function (a, b) DOM(a).rect.top < DOM(b).rect.top ? a : b;
@@ -529,11 +530,8 @@ var Buffer = Module("Buffer", {
let ranges = getRanges(rect); let ranges = getRanges(rect);
if (!ranges.length) if (!ranges.length)
ranges = getRanges({ x: 0, y: y, width: win.innerWidth, height: 0 }); ranges = getRanges({ x: 0, y: y, width: win.innerWidth, height: 0 });
if (!ranges.length && !sel.rangeCount)
ranges = [RangeFind.nodeContents(doc.body || doc.querySelector("body") || doc.documentElement)];
if (!ranges.length)
return;
if (ranges.length) {
range = ranges.reduce(reduce); range = ranges.reduce(reduce);
if (range) { if (range) {
@@ -552,6 +550,11 @@ var Buffer = Module("Buffer", {
sel.modify("move", reverse ? "forward" : "backward", "lineboundary"); sel.modify("move", reverse ? "forward" : "backward", "lineboundary");
} }
}
if (!sel.rangeCount)
sel.collapse(doc.body || doc.querySelector("body") || doc.documentElement,
0);
}, },
/** /**

View File

@@ -95,7 +95,7 @@ var RangeFinder = Module("rangefinder", {
this.options["findflags"].forEach(function (f) replacer(f, f)); this.options["findflags"].forEach(function (f) replacer(f, f));
str = str.replace(/\\(.|$)/g, replacer); let pattern = str.replace(/\\(.|$)/g, replacer);
// It's possible, with :tabdetach for instance, for the rangeFind to // It's possible, with :tabdetach for instance, for the rangeFind to
// actually move from one window to another, which breaks things. // actually move from one window to another, which breaks things.
@@ -114,7 +114,9 @@ var RangeFinder = Module("rangefinder", {
this.rangeFind.highlighted = highlighted; this.rangeFind.highlighted = highlighted;
this.rangeFind.selections = selections; this.rangeFind.selections = selections;
} }
return this.lastFindPattern = str; if (str)
this.lastFindPattern = str;
return pattern;
}, },
find: function (pattern, backwards) { find: function (pattern, backwards) {
@@ -168,6 +170,12 @@ var RangeFinder = Module("rangefinder", {
}, },
onSubmit: function (command) { onSubmit: function (command) {
if (!command && this.lastFindPattern) {
this.find(this.lastFindPattern, this.backward);
this.findAgain();
return;
}
if (!this.options["incfind"] || !this.rangeFind || !this.rangeFind.found) { if (!this.options["incfind"] || !this.rangeFind || !this.rangeFind.found) {
this.clear(); this.clear();
this.find(command || this.lastFindPattern, this.backward); this.find(command || this.lastFindPattern, this.backward);