From 6f8f652086bdb03c2a8baea0b9fb8c0b29afa7a9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 4 Oct 2012 11:57:25 +0200 Subject: [PATCH] [simplehint util] Support completeSingle option To turn off the behavior where it'll always complete when only a single option is left. --- lib/util/simple-hint.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/util/simple-hint.js b/lib/util/simple-hint.js index f42e787f07..04ae4af8b5 100644 --- a/lib/util/simple-hint.js +++ b/lib/util/simple-hint.js @@ -25,7 +25,10 @@ editor.replaceRange(str, result.from, result.to); } // When there is only one completion, use it directly. - if (completions.length == 1) {insert(completions[0]); return true;} + if (options.completeSingle && completions.length == 1) { + insert(completions[0]); + return true; + } // Build the select widget var complete = document.createElement("div"); @@ -92,6 +95,7 @@ }; CodeMirror.simpleHint.defaults = { closeOnBackspace: true, - closeOnTokenChange: false + closeOnTokenChange: false, + completeSingle: true }; })();