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

Commit b9c89f2

Browse files
shubhsnovswmitra
authored andcommitted
CodeHint Related Bug Fixes (#14692)
1 parent 5658e3d commit b9c89f2

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/extensions/default/PhpTooling/CodeHintsProvider.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,15 @@ define(function (require, exports, module) {
101101

102102
self.query = context.token.string.slice(0, context.pos.ch - context.token.start);
103103
if (msgObj) {
104-
var res = msgObj.items || [];
104+
var res = msgObj.items || [],
105+
trimmedQuery = self.query.trim(),
106+
hasIgnoreCharacters = self.ignoreQuery.includes(implicitChar) || self.ignoreQuery.includes(trimmedQuery),
107+
isExplicitInvokation = implicitChar === null;
108+
105109
// There is a bug in Php Language Server, Php Language Server does not provide superGlobals
106110
// Variables as completion. so these variables are being explicity put in response objects
107111
// below code should be removed if php server fix this bug.
108-
if(self.query) {
112+
if((isExplicitInvokation || trimmedQuery) && !hasIgnoreCharacters) {
109113
for(var key in phpSuperGlobalVariables) {
110114
res.push({
111115
label: key,
@@ -115,7 +119,12 @@ define(function (require, exports, module) {
115119
}
116120
}
117121

118-
var filteredHints = filterWithQueryAndMatcher(res, self.query);
122+
var filteredHints = [];
123+
if (hasIgnoreCharacters || (isExplicitInvokation && !trimmedQuery)) {
124+
filteredHints = filterWithQueryAndMatcher(res, "");
125+
} else {
126+
filteredHints = filterWithQueryAndMatcher(res, self.query);
127+
}
119128

120129
StringMatch.basicMatchSort(filteredHints);
121130
filteredHints.forEach(function (element) {

src/languageTools/DefaultProviders.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ define(function (require, exports, module) {
4646
function CodeHintsProvider(client) {
4747
this.client = client;
4848
this.query = "";
49+
this.ignoreQuery = ["-", "->", ">", ":", "::", "(", "()", ")", "[", "[]", "]", "{", "{}", "}"];
4950
}
5051

5152
function formatTypeDataForToken($hintObj, token) {
@@ -160,11 +161,12 @@ define(function (require, exports, module) {
160161
token = $hint.data("token"),
161162
txt = null,
162163
query = this.query,
164+
shouldIgnoreQuery = this.ignoreQuery.includes(query),
165+
inclusion = shouldIgnoreQuery ? "" : query,
163166
start = {
164167
line: cursor.line,
165-
ch: cursor.ch - query.length
168+
ch: cursor.ch - inclusion.length
166169
},
167-
168170
end = {
169171
line: cursor.line,
170172
ch: cursor.ch

0 commit comments

Comments
 (0)