diff --git a/content/completion.js b/content/completion.js index 134236ab..ec16cd5a 100644 --- a/content/completion.js +++ b/content/completion.js @@ -1183,7 +1183,6 @@ function Completion() //{{{ // dynamically get completions as specified with the command's completer function let command = commands.get(cmd); - let compObject = { start: 0, items: [] }; if (!command) { context.highlight(0, cmd.length, "SPELLCHECK"); @@ -1204,7 +1203,7 @@ function Completion() //{{{ cmdContext.advance(args.completeStart); cmdContext.quote = args.quote; cmdContext.filter = args.completeFilter; - compObject = command.completer.call(command, cmdContext, args); + let compObject = command.completer.call(command, cmdContext, args); if (compObject instanceof Array) // for now at least, let completion functions return arrays instead of objects compObject = { start: compObject[0], items: compObject[1] }; if (compObject != null) diff --git a/content/ui.js b/content/ui.js index c9b799c9..bad3639e 100644 --- a/content/ui.js +++ b/content/ui.js @@ -792,7 +792,14 @@ function CommandLine() //{{{ onEvent: function onEvent(event) { - var command = this.getCommand(); + let command = this.getCommand(); + let editor = commandWidget.inputField.editor; + try + { + let node = editor.rootElement; + node.removeChild(node.firstChild.nextSibling); + } + catch (e) {} if (event.type == "blur") { @@ -818,6 +825,16 @@ function CommandLine() //{{{ else if (event.type == "input") { liberator.triggerCallback("change", currentExtendedMode, command); + // Kludge. Major kludge. + let wildmode = options.get("wildmode"); + let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)]; + if (wildmode.checkHas(wildType, "longest")) + { + let start = commandWidget.selectionStart; + let substring = completionContext.longestAllSubstring.substr(start - completionContext.allItems.start); + editor.insertNode(util.xmlToDom({substring}, document), editor.rootElement, 1); + commandWidget.selectionStart = commandWidget.selectionEnd = start; + } } else if (event.type == "keypress") {