Created
December 24, 2010 02:06
-
-
Save teramako/753811 to your computer and use it in GitHub Desktop.
Vimpreator patch: fix wrong completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 145d4c50d6b4 common/content/commandline.js | |
--- a/common/content/commandline.js Fri Dec 24 10:23:40 2010 +0900 | |
+++ b/common/content/commandline.js Fri Dec 24 11:04:18 2010 +0900 | |
@@ -1118,7 +1118,7 @@ | |
*/ | |
Completions: Class("Completions", { | |
init: function (input) { | |
- this.context = CompletionContext(input.editor); | |
+ this.context = CompletionContext(input); | |
this.context.onUpdate = this.closure._reset; | |
this.editor = input.editor; | |
this.selected = null; | |
diff -r 145d4c50d6b4 common/content/completion.js | |
--- a/common/content/completion.js Fri Dec 24 10:23:40 2010 +0900 | |
+++ b/common/content/completion.js Fri Dec 24 11:04:18 2010 +0900 | |
@@ -16,9 +16,11 @@ | |
* the creation of sub-contexts with different headers and quoting | |
* rules. | |
* | |
- * @param {nsIEditor} editor The editor for which completion is | |
+ * @param {HTMLInputElement} input The editor for which completion is | |
* intended. May be a {CompletionContext} when forking a context, | |
* or a {string} when creating a new one. | |
+ * XXX: https://bugzilla.mozilla.org/show_bug.cgi?id=618563 editor.focusOffset returns wrong value | |
+ * so requires HTMLInputElement instead nsIEditor | |
* @param {string} name The name of this context. Used when the | |
* context is forked. | |
* @param {number} offset The offset from the parent context. | |
@@ -26,13 +28,13 @@ | |
* @constructor | |
*/ | |
const CompletionContext = Class("CompletionContext", { | |
- init: function (editor, name, offset) { | |
+ init: function (input, name, offset) { | |
if (!name) | |
name = ""; | |
let self = this; | |
- if (editor instanceof this.constructor) { | |
- let parent = editor; | |
+ if (input instanceof this.constructor) { | |
+ let parent = input; | |
name = parent.name + "/" + name; | |
this.contexts = parent.contexts; | |
if (name in this.contexts) | |
@@ -48,7 +50,7 @@ | |
["filters", "keys", "title", "quote"].forEach(function (key) | |
self[key] = parent[key] && util.cloneObject(parent[key])); | |
- ["anchored", "compare", "editor", "_filter", "filterFunc", "keys", "_process", "top"].forEach(function (key) | |
+ ["anchored", "compare", "editor", "inputField", "_filter", "filterFunc", "keys", "_process", "top"].forEach(function (key) | |
self[key] = parent[key]); | |
self.__defineGetter__("value", function () this.top.value); | |
@@ -80,10 +82,12 @@ | |
}); | |
} | |
else { | |
- if (typeof editor == "string") | |
- this._value = editor; | |
- else | |
- this.editor = editor; | |
+ if (typeof input == "string") | |
+ this._value = input; | |
+ else { | |
+ this.inputField = input; | |
+ this.editor = input.editor; | |
+ } | |
this.compare = function (a, b) String.localeCompare(a.text, b.text); | |
/** | |
@@ -583,7 +587,7 @@ | |
if (this.editor) { | |
this.value = this.editor.selection.focusNode.textContent; | |
- this._caret = this.editor.selection.focusOffset; | |
+ this._caret = this.inputField.selectionEnd; | |
} | |
else { | |
this.value = this._value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment