Skip to content

Commit

Permalink
Pass along cursor position from QueryBox
Browse files Browse the repository at this point in the history
  • Loading branch information
danvk committed Dec 4, 2014
1 parent 0a17fca commit a16ccab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cycledash/static/js/QueryCompletion.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function getInternalCompletions(query, parse, columnNames, cursorPosition) {
* The cursor is assumed to be at the end of the string, unless specified.
*/
function getCompletions(query, parse, columnNames, opt_cursorPosition) {
if (opt_cursorPosition !== undefined) {
if (opt_cursorPosition !== undefined && opt_cursorPosition < query.length) {
return getInternalCompletions(query, parse, columnNames, opt_cursorPosition);
}

Expand Down
4 changes: 3 additions & 1 deletion cycledash/static/js/examine/components/QueryBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ var QueryBox = React.createClass({
minLength: 0
}, {
name: 'my-dataset',
source: completionSource
source: function(q, callback) {
return completionSource(q, callback, $input.get(0).selectionStart);
}
})
.on('input typeahead:autocompleted', handleChange)
.on('keydown', (e) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/playground/typeahead.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h1>Typeahead CQL demo</h1>
name: 'my-dataset',
source: function(q, callback) {
checkSyntax(q);
mySource(q, callback);
mySource(q, callback, $('#input').get(0).selectionStart);
}
})
.on('change', checkSyntax);
Expand Down

0 comments on commit a16ccab

Please sign in to comment.