1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 04:07:59 +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

@@ -99,8 +99,8 @@ dist: $(XPI)
$(RDF): $(RDF_IN) Makefile
@echo "Preparing release..."
$(SED) -e "s,###VERSION###,$(VERSION),g" \
-e "s,###DATE###,$(BUILD_DATE),g" \
$(SED) -e "s,@VERSION@,$(VERSION),g" \
-e "s,@DATE@,$(BUILD_DATE),g" \
< $< > $@
@echo "SUCCESS: $@"

View File

@@ -656,9 +656,12 @@ 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) {
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

@@ -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,14 +59,17 @@ 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))
try {
if (obj.hasOwnProperty(k) == toplevel)
yield [k, this.getKey(obj, k)];
}
catch (e) {}
}
},
// Search the object for strings starting with @key.
@@ -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

View File

@@ -18,8 +18,8 @@ getfiles () {
find "$@" -not -path '*\.hg*' 2>/dev/null | grep -E "$filter" || true
}
copytext () {
sed -e "s,###VERSION###,$VERSION,g" \
-e "s,###DATE###,$BUILD_DATE,g" \
sed -e "s,@VERSION@,$VERSION,g" \
-e "s,@DATE@,$BUILD_DATE,g" \
<"$1" >"$2"
cmp -s "$1" "$2" ||
( echo "modified: $1"; diff -u "$1" "$2" | grep '^[-+][^-+]' )

View File

@@ -42,7 +42,6 @@ BUGS:
FEATURES:
8 Document Textarea, Caret and Visual modes.
8 Incremental searches should retreat to their starting position on <Backspace>
8 Replace config.name tests in liberator with more specific feature
tests or overridable APIs where at all feasible.
8 change the extension ID to vimperator@vimperator.org rather than
@@ -65,25 +64,11 @@ FEATURES:
8 :redir and 'verbosefile'
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer
8 all search commands should start searching from the top of the visible viewport
8 :addsearch wikpedia http://en.wikipedia.org/wiki/Special:Search?search=%s to allow saving of
quick searches in the RC file.
Why not just add a bookmark? --Kris
This would require performance tests, how fast it is to add 20 keywords that way, as we need
to search all existing bookmarks to see if the keyword is already defined, and then just update
that bookmark. --mst
Wah? I don't see how that's especially relevant, since they only
need to be added once, but, if you insist:
:100time bookmarks.getKeywords().some(function(k) k.keyword == "wikipedia")
Code execution summary
Executed: 100 times
Average time: 2.48 msec
Total time: 0.25 sec
--Kris
8 allow for multiple ex commands separated with | (see #24)
8 <C-o>/<C-i> should work as in vim (i.e., save page positions as well as
locations in the history list).
8 jump to the next heading with ]h, next image ]i, previous textbox [t and so on
8 pipe selected text/link/website to an external command
7 use ctrl-n/p in insert mode for word completion
7 implement QuickFix window based on ItemList
7 wherever possible: get rid of dialogs and ask console-like dialog questions
@@ -93,7 +78,7 @@ FEATURES:
opera's fast forward does something like this
7 make an option to disable session saving by default when you close Firefox
7 The output of the pageinfo-command should contain the security-information of ssl-encrypted sites
7 Add :every command
7 :grep support (needs location list)
6 :mksession
6 add [count] support to :b* and :tab* commands where missing
6 registers
@@ -101,12 +86,10 @@ FEATURES:
always be the default register. --Ted
6 check/correct spellings in insert mode with some mappings
6 add more autocommands (TabClose, TabOpen, TabChanged etc)
6 jump to the next heading with ]h, next image ]i, previous textbox [t and so on
6 :grep support (needs location list)
6 pipe selected text/link/website to an external command
6 Use ctrl-w+j/k/w to switch between sidebar, content, preview window
6 Command :tags for getting a list of used tags
6 ;?<hint> should show more information
6 Add information to liberator/HACKING file about testing and optimization
5 when looking at a zoomed out image (because it's large), zi should zoom in
maybe with this? : http://mxr.mozilla.org/seamonkey/source/content/html/document/public/nsIImageDocument.idl
5 make a command to search within google search results
@@ -117,8 +100,5 @@ FEATURES:
3 add a command-line window (:help cmdline-window in Vim).
3 Splitting Windows with [:sp :vsp ctrl-w,s ctrl-w,v] and closing with [ctrl-w,q], moving with [ctrl-w,w or tab]
have a look into the split browser extension
1 Add information to liberator/HACKING file about testing and optimization
1 Document remote branches in liberator/HACKING
1 Reformat liberator/HACKING so that git diff can find sections and report changes @ somewhere
- many other ideas are listed in the wiki

View File

@@ -4,7 +4,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>vimperator@mozdev.org</em:id>
<em:name>Vimperator</em:name>
<em:version>###VERSION###</em:version>
<em:version>@VERSION@</em:version>
<em:description>Make Firefox behave like Vim</em:description>
<em:creator>Martin Stubenschrott</em:creator>
<em:homepageURL>http://vimperator.org</em:homepageURL>