From 082d9d12fa522c8ec81d1259103ce743f59a0d14 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 28 Nov 2008 09:02:03 +0000 Subject: [PATCH] Dont show substring preview when caret isnt at end of line. Fix unanchored substring generation. --- content/buffer.js | 2 +- content/completion.js | 9 +++++---- content/options.js | 4 +--- content/ui.js | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/content/buffer.js b/content/buffer.js index df1e96c2..8263bbaa 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -495,8 +495,8 @@ function Buffer() //{{{ argCount: "?", completer: function (context) { - context.title = ["Page Info"]; completion.optionValue(context, "pageinfo", "+", ""); + context.title = ["Page Info"]; } }); diff --git a/content/completion.js b/content/completion.js index a86e7d0a..291a0ed9 100644 --- a/content/completion.js +++ b/content/completion.js @@ -314,7 +314,7 @@ CompletionContext.prototype = { let start = 0; let idx; let length = filter.length; - while ((idx = text.indexOf(filter, start)) > -1 && idx < length) + while ((idx = text.indexOf(filter, start)) > -1 && idx < text.length) { for (let end in util.range(idx + length, text.length + 1)) substrings.push(text.substring(idx, end)); @@ -1372,12 +1372,13 @@ function Completion() //{{{ // TODO: Highlight when invalid context.advance(context.filter.length - len); - /* Not vim compatible, but is a significant enough improvement - * that it's worth breaking compatibility. - */ + context.title = ["Option Value"]; let completions = completer(context); if (!completions) return; + /* Not vim compatible, but is a significant enough improvement + * that it's worth breaking compatibility. + */ if (newValues instanceof Array) { completions = completions.filter(function (val) newValues.indexOf(val[0]) == -1); diff --git a/content/options.js b/content/options.js index 6ac9356c..8e772000 100644 --- a/content/options.js +++ b/content/options.js @@ -695,9 +695,8 @@ function Options() //{{{ else if (prefix == "no") return; - let [name, value] = context.filter.split("=", 2); let option = opt.option; - context.advance(name.length + 1); + context.advance(context.filter.indexOf("=") + 1); if (!option) context.highlight(0, name.length, "SPELLCHECK"); @@ -713,7 +712,6 @@ function Options() //{{{ }); } - context.title = ["Option Value"]; completion.optionValue(context, opt.name, opt.operator); }, literal: true, diff --git a/content/ui.js b/content/ui.js index 8260625b..047d21cf 100644 --- a/content/ui.js +++ b/content/ui.js @@ -319,7 +319,7 @@ function CommandLine() //{{{ catch (e) {} let wildmode = options.get("wildmode"); let wildType = wildmode.values[Math.min(wildIndex, wildmode.values.length - 1)]; - if (wildmode.checkHas(wildType, "longest")) + if (wildmode.checkHas(wildType, "longest") && commandWidget.selectionStart == commandWidget.value.length) { // highlight= won't work here. let start = commandWidget.selectionStart;