Fix greediness of autocompletion

(closes #3077)
This commit is contained in:
Kushan Joshi
2016-05-10 16:41:13 +05:30
parent 2ed9b19dbe
commit 59ef7d93db

View File

@@ -180,11 +180,16 @@ d3.combobox = function() {
});
}
function isCursorNotAtEnd() {
return input.property('selectionStart') < input.property('value').length;
}
function autocomplete() {
var v = caseSensitive ? value() : value().toLowerCase();
idx = -1;
if (!v) return;
if (!v) return;
v = isCursorNotAtEnd() ? input.property('value'): v;
for (var i = 0; i < suggestions.length; i++) {
var suggestion = suggestions[i].value,
compare = caseSensitive ? suggestion : suggestion.toLowerCase();