Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
CodeHint Related Bug Fixes (#14692)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhsnov authored and swmitra committed Apr 10, 2019
1 parent 5658e3d commit b9c89f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/extensions/default/PhpTooling/CodeHintsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions src/languageTools/DefaultProviders.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ define(function (require, exports, module) {
function CodeHintsProvider(client) {
this.client = client;
this.query = "";
this.ignoreQuery = ["-", "->", ">", ":", "::", "(", "()", ")", "[", "[]", "]", "{", "{}", "}"];
}

function formatTypeDataForToken($hintObj, token) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b9c89f2

Please sign in to comment.