-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix for PHPCodeHints invocation failure scenarios #14692
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ define(function (require, exports, module) { | |
function CodeHintsProvider(client) { | ||
this.client = client; | ||
this.query = ""; | ||
this.ignoreQuery = ["-", "->", ">", ":", "::", "(", "()", ")", "[", "[]", "]", "{", "{}", "}"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you have added this list to the defaultprovider, the ignorequery list will be different for different languages. why should this be here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could have made it specific to PHP but the CodeHintProvider for PHP was using the insertHint from the DefaultProvider, and we needed to know if any query needed to be ignored there as well. Secondly, this was something that would affect most languages. For PHP I could have stopped at "->" and ":" but then decided to take a more generic approach by including the braces as well, as these things need to be ignored by most languages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, |
||
} | ||
|
||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to filter hints. isn't server itself sending filtered hints based on the query??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filtering here is required for creating stringRanges, and matchGoodness, which are then used to highlight the matched text and sort the things accordingly as per the query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the purpose is to create stringRanges, and matchGoodness, then why this function removes some of hints from hintlist retured from server??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make change here that none of the hints returned from server should be removed?
If we can do this then we will not have to worry about ignoreCharacters list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand. The characters in ignoreList are from the query, not the hints. In essence, I am actually doing the same thing you have suggested. The query is being saved on the Brackets side for a session. So when a user types "se" the results are then filtered by calculating the distance of the hint from the subsequence "se". The results are then sorted by the distance. When a user types something like "->" which is not part of the hint but still invokes hints, I am just not using "->" to filter out the hints, rather preserving the order of the hints as they come.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shubhsnov
I feel same thing can be done without maintaining an ignore characters list in codeHintsProvider
make change in filterWithQueryAndMatcher function.
Pass a boolean parameter(dontRemoveIfNoMatch) to this function. if this third parameter is true none of the hints should be removed even if hints has no match with query.
call this "filterWithQueryAndMatcher" for server hints with dontRemoveIfNoMatch as true.
and call this function separately for static hints with dontRemoveIfNoMatch as false which is default.
lets think if we can do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need the list to determine if we have to ignore the query length in insertHint. Using the list to maintain consistency across the session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niteskum
filterWithQueryAndMatcher
implementation shouldn't be changed as there are multiple extensions using this fn. This is more generic implementation which shouldn't be altered for code hint listing use cases.