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

Fix broken JS completion.

--HG--
branch : testing
This commit is contained in:
Kris Maglione
2010-06-03 20:24:16 -04:00
parent b6267c4f19
commit a6f90714e4
11 changed files with 51 additions and 53 deletions

View File

@@ -656,8 +656,11 @@ const Bookmarks = Module("bookmarks", {
let rest = item.url.length - end.length;
let query = item.url.substring(begin.length, rest);
if (item.url.substr(rest) == end && query.indexOf("&") == -1) {
item.url = decodeURIComponent(query.replace(/#.*/, ""));
return item;
try {
item.url = decodeURIComponent(query.replace(/#.*/, ""));
return item;
}
catch (e) {}
}
return null;
}).filter(util.identity);

View File

@@ -169,7 +169,7 @@ const Buffer = Module("buffer", {
// called when the active document is scrolled
_updateBufferPosition: function _updateBufferPosition() {
statusline.updateBufferPosition();
modes.show();
modes.show(); // Clear the status line.
},
onDOMContentLoaded: function onDOMContentLoaded(event) {
@@ -283,6 +283,7 @@ const Buffer = Module("buffer", {
setTimeout(function () {
statusline.updateBufferPosition();
statusline.updateZoomLevel();
modes.show(); // Clear the status line.
}, 500);
},
// called at the very end of a page load

View File

@@ -361,7 +361,7 @@ const RangeFind = Class("RangeFind", {
// This doesn't work yet.
resetCaret: function () {
let equal = RangeFind.equal;
letselection = this.win.getSelection();
let selection = this.win.getSelection();
if (selection.rangeCount == 0)
selection.addRange(this.pageStart);
function getLines() {
@@ -627,7 +627,13 @@ const RangeFind = Class("RangeFind", {
range.collapse(before);
return range;
},
equal: function (r1, r2) !r1.compareBoundaryPoints(Range.START_TO_START, r2) && !r1.compareBoundaryPoints(Range.END_TO_END, r2)
equal: function (r1, r2) {
try {
return !r1.compareBoundaryPoints(Range.START_TO_START, r2) && !r1.compareBoundaryPoints(Range.END_TO_END, r2)
}
catch (e) {}
return false;
}
});
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -268,7 +268,7 @@ const Hints = Module("hints", {
let hint = { elem: elem, showText: false };
// TODO: for iframes, this calculation is wrong
rect = elem.getBoundingClientRect();
let rect = elem.getBoundingClientRect();
if (!rect || rect.top > height || rect.bottom < 0 || rect.left > width || rect.right < 0)
continue;

View File

@@ -37,7 +37,10 @@ const JavaScript = Module("javascript", {
let seen = {};
let ret = {};
try {
if(obj == null)
return;
if(options["jsdebugger"]) {
let orig = obj;
let top = services.get("debugger").wrapValue(obj);
@@ -56,13 +59,16 @@ const JavaScript = Module("javascript", {
}
// The debugger doesn't list some properties. I can't guess why.
for (let k in orig)
if (k in orig && !('|' + k in seen) && obj.hasOwnProperty(k) == toplevel)
if (k in orig && !('|' + k in seen) && orig.hasOwnProperty(k) == toplevel)
yield [k, this.getKey(orig, k)]
}
catch(e) {
else {
for (k in allkeys(obj))
if (obj.hasOwnProperty(k) == toplevel)
yield [k, this.getKey(obj, k)];
try {
if (obj.hasOwnProperty(k) == toplevel)
yield [k, this.getKey(obj, k)];
}
catch (e) {}
}
},
@@ -230,8 +236,6 @@ const JavaScript = Module("javascript", {
case "'":
case "/":
case "{":
this._push(this._c);
break;
case "[":
this._push(this._c);
break;
@@ -341,6 +345,10 @@ const JavaScript = Module("javascript", {
_complete: function (objects, key, compl, string, last) {
const self = this;
if(!options["jsdebugger"] && !this.context.message)
this.context.message = "For better completion data, please enable the JavaScript debugger (:set jsdebugger)";
let orig = compl;
if (!compl) {
compl = function (context, obj, recurse) {
@@ -427,7 +435,8 @@ const JavaScript = Module("javascript", {
// Okay, have parse stack. Figure out what we're completing.
// Find any complete statements that we can eval before we eval our object.
// This allows for things like: let doc = window.content.document; let elem = doc.createElement...; elem.<Tab>
// This allows for things like:
// let doc = window.content.document; let elem = doc.createEle<Tab> ...
let prev = 0;
for (let [, v] in Iterator(this._get(0).fullStatements)) {
let key = this._str.substring(prev, v + 1);
@@ -437,14 +446,13 @@ const JavaScript = Module("javascript", {
prev = v + 1;
}
// In a string. Check if we're dereferencing an object.
// Otherwise, do nothing.
// In a string. Check if we're dereferencing an object or
// completing a function argument. Otherwise, do nothing.
if (this._last == "'" || this._last == '"') {
//
// str = "foo[bar + 'baz"
// obj = "foo"
// key = "bar + ''"
//
// The top of the stack is the sting we're completing.
// Wrap it in its delimiters and eval it to process escape sequences.
@@ -520,7 +528,7 @@ const JavaScript = Module("javascript", {
return null;
}
//
// str = "foo.bar.baz"
// obj = "foo.bar"
// key = "baz"
@@ -528,11 +536,11 @@ const JavaScript = Module("javascript", {
// str = "foo"
// obj = [modules, window]
// key = "foo"
//
let [offset, obj, key] = this._getObjKey(-1);
// Wait for a keypress before completing the default objects.
// Wait for a keypress before completing when there's no key
if (!this.context.tabPressed && key == "" && obj.length > 1) {
this.context.waitingForTab = true;
this.context.message = "Waiting for key press";

View File

@@ -136,7 +136,7 @@ const Liberator = Module("liberator", {
forceNewWindow: false,
/** @property {string} The Liberator version string. */
version: "###VERSION### (created: ###DATE###)", // these VERSION and DATE tokens are replaced by the Makefile
version: "@VERSION@ (created: @DATE@)", // these VERSION and DATE tokens are replaced by the Makefile
/**
* @property {Object} The map of command-line options. These are
@@ -331,7 +331,7 @@ const Liberator = Module("liberator", {
// you don't like them you can set verbose=0, or use :silent when
// someone adds it. I reckon another flag and 'class' of messages
// is just going to unnecessarily complicate things. --djk
flags |= commandline.APPEND_TO_MESSAGES | commandline.DISALLOW_MULTILINE;
flags |= commandline.APPEND_TO_MESSAGES; // | commandline.DISALLOW_MULTILINE;
if (verbosity == null)
verbosity = 0; // verbosity level is exclusionary

View File

@@ -726,7 +726,7 @@ const Util = Module("util", {
// Ok, not a valid proto. If it looks like URL-ish (foo.com/bar),
// let Gecko figure it out.
if (/[.\/]/.test(url) && !/\s/.test(url) || /^[\w-.]+:\d+(?:\/|$)/.test(url))
if (/^[a-zA-Z0-9-.]+(?:\/|$)/.test(url) && /[.\/]/.test(url) && !/\s/.test(url) || /^[a-zA-Z0-9-.]+:\d+(?:\/|$)/.test(url))
return url;
// TODO: it would be clearer if the appropriate call to