diff --git a/src/extensions/default/PhpTooling/CodeHintsProvider.js b/src/extensions/default/PhpTooling/CodeHintsProvider.js index 937f26476eb..784c4e21797 100644 --- a/src/extensions/default/PhpTooling/CodeHintsProvider.js +++ b/src/extensions/default/PhpTooling/CodeHintsProvider.js @@ -101,11 +101,15 @@ define(function (require, exports, module) { self.query = context.token.string.slice(0, context.pos.ch - context.token.start); if (msgObj) { - var res = msgObj.items || []; + var res = msgObj.items || [], + trimmedQuery = self.query.trim(), + hasIgnoreCharacters = self.ignoreQuery.includes(implicitChar) || self.ignoreQuery.includes(trimmedQuery), + isExplicitInvokation = implicitChar === null; + // There is a bug in Php Language Server, Php Language Server does not provide superGlobals // Variables as completion. so these variables are being explicity put in response objects // below code should be removed if php server fix this bug. - if(self.query) { + if((isExplicitInvokation || trimmedQuery) && !hasIgnoreCharacters) { for(var key in phpSuperGlobalVariables) { res.push({ label: key, @@ -115,7 +119,12 @@ define(function (require, exports, module) { } } - var filteredHints = filterWithQueryAndMatcher(res, self.query); + var filteredHints = []; + if (hasIgnoreCharacters || (isExplicitInvokation && !trimmedQuery)) { + filteredHints = filterWithQueryAndMatcher(res, ""); + } else { + filteredHints = filterWithQueryAndMatcher(res, self.query); + } StringMatch.basicMatchSort(filteredHints); filteredHints.forEach(function (element) { diff --git a/src/languageTools/DefaultProviders.js b/src/languageTools/DefaultProviders.js index 6339ace3277..fbeb67e36ec 100644 --- a/src/languageTools/DefaultProviders.js +++ b/src/languageTools/DefaultProviders.js @@ -46,6 +46,7 @@ define(function (require, exports, module) { function CodeHintsProvider(client) { this.client = client; this.query = ""; + this.ignoreQuery = ["-", "->", ">", ":", "::", "(", "()", ")", "[", "[]", "]", "{", "{}", "}"]; } function formatTypeDataForToken($hintObj, token) { @@ -160,11 +161,12 @@ define(function (require, exports, module) { token = $hint.data("token"), txt = null, query = this.query, + shouldIgnoreQuery = this.ignoreQuery.includes(query), + inclusion = shouldIgnoreQuery ? "" : query, start = { line: cursor.line, - ch: cursor.ch - query.length + ch: cursor.ch - inclusion.length }, - end = { line: cursor.line, ch: cursor.ch