mirror of
https://github.com/RustyRaptor/brackets.git
synced 2026-12-04 00:15:22 -07:00
case insensitive matches, middle matching, and use tern rawCompletions request
This commit is contained in:
1 parent
cb4e0c6e92
commit
f4bcdfc13c
5 files changed
+34
-9
No files matched your search
@@ -424,7 +424,7 @@ define(function (require, exports, module) {
|
||||
return request;
|
||||
}
|
||||
|
||||
var request = buildRequest(dir, file, "completions", offset);
|
||||
var request = buildRequest(dir, file, "rawCompletions", offset);
|
||||
var ternHints = [];
|
||||
ternServer.request(request, function(error, data) {
|
||||
//if (error) return displayError(error);
|
||||
|
||||
@@ -541,6 +541,7 @@ define(function (require, exports, module) {
|
||||
var ternHints = ScopeManager.getTernHints("dir", "file", offset, this.editor.document.getText());
|
||||
if( ternHints && ternHints.length > 0 ) {
|
||||
hints = ternHints;
|
||||
hints.sort(compareByName);
|
||||
}
|
||||
else{
|
||||
hints = copyHints(this.properties);
|
||||
|
||||
@@ -42,7 +42,8 @@ define(function (require, exports, module) {
|
||||
cachedScope = null, // the inner-most scope returned by the query worker
|
||||
cachedLine = null; // the line number for the cached scope
|
||||
|
||||
var MAX_DISPLAYED_HINTS = 100;
|
||||
var MAX_DISPLAYED_HINTS = 100,
|
||||
QUERY_PREFIX_LENGTH = 1; // Any query of this size or less is matched as a prefix of a hint.
|
||||
|
||||
/**
|
||||
* Creates a hint response object. Filters the hint list using the query
|
||||
@@ -102,7 +103,11 @@ define(function (require, exports, module) {
|
||||
if (trimmedQuery !== query) {
|
||||
return filterArrayPrefix(tokens, function (token) {
|
||||
if (token.literal && token.kind === "string") {
|
||||
return (token.value.indexOf(trimmedQuery) === 0);
|
||||
if (query.length > (QUERY_PREFIX_LENGTH + 1)) {
|
||||
return (token.value.toLowerCase().indexOf(trimmedQuery.toLowerCase()) !== -1);
|
||||
} else {
|
||||
return (token.value.toLowerCase().indexOf(trimmedQuery.toLowerCase()) === 0);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -112,7 +117,11 @@ define(function (require, exports, module) {
|
||||
if (token.literal && token.kind === "string") {
|
||||
return false;
|
||||
} else {
|
||||
return (token.value.indexOf(query) === 0);
|
||||
if (query.length > QUERY_PREFIX_LENGTH) {
|
||||
return (token.value.toLowerCase().indexOf(query.toLowerCase()) !== -1);
|
||||
} else {
|
||||
return (token.value.toLowerCase().indexOf(query.toLowerCase()) === 0);
|
||||
}
|
||||
}
|
||||
}, limit);
|
||||
} else {
|
||||
@@ -131,9 +140,24 @@ define(function (require, exports, module) {
|
||||
* objects
|
||||
*/
|
||||
function formatHints(hints, query) {
|
||||
if (query.length > QUERY_PREFIX_LENGTH) {
|
||||
hints.sort(function (hint1, hint2) {
|
||||
var index1 = hint1.value.toLowerCase().indexOf(query.toLowerCase()),
|
||||
index2 = hint2.value.toLowerCase().indexOf(query.toLowerCase());
|
||||
|
||||
if (index1 === 0 && index2 !== 0) {
|
||||
return -1;
|
||||
} else if (index1 !== 0 && index2 === 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
return hints.map(function (token) {
|
||||
var hint = token.value,
|
||||
index = hint.indexOf(query),
|
||||
index = hint.toLowerCase().indexOf(query.toLowerCase()),
|
||||
$hintObj = $("<span>").addClass("brackets-js-hints"),
|
||||
delimiter = "";
|
||||
|
||||
|
||||
Reference in new issue
Block a user