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

Commit 07ddd05

Browse files
committed
Merge pull request #10242 from adobe/rlim/no-hints-in-regex
Don't show hints inside a regexp.
2 parents 6aaa072 + b4267c2 commit 07ddd05

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/extensions/default/JavaScriptCodeHints/HintUtils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ define(function (require, exports, module) {
8080
* @return {boolean} - could the token be hintable?
8181
*/
8282
function hintable(token) {
83+
84+
function _isInsideRegExp(token) {
85+
return token.state && (token.state.lastType === "regexp" ||
86+
(token.state.localState && token.state.localState.lastType === "regexp"));
87+
}
88+
8389
switch (token.type) {
8490
case "comment":
8591
case "number":
@@ -88,6 +94,9 @@ define(function (require, exports, module) {
8894
// exclude variable & param decls
8995
case "def":
9096
return false;
97+
case "string-2":
98+
// exclude strings inside a regexp
99+
return !_isInsideRegExp(token);
91100
default:
92101
return true;
93102
}

0 commit comments

Comments
 (0)