Skip to content

Commit f1e6d2a

Browse files
author
Chris K
committed
Fix for DFL-3310, Syntax error when auto-completing after "in".
1 parent 7040366 commit f1e6d2a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/repl/propertyfinder.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@ window.cls.PropertyFinder = function(rt_id) {
2727
this._parser = window.simple_js_parser || new window.cls.SimpleJSParser();
2828

2929
const PUNCTUATOR = cls.SimpleJSParser.PUNCTUATOR;
30+
const IDENTIFIER = cls.SimpleJSParser.IDENTIFIER;
3031
const TYPE = 0;
3132
const VALUE = 1;
3233

33-
this._get_last_punctuator = function(tokens, punctuator)
34+
this._get_last_token = function(tokens, token_type, token_value)
3435
{
3536
if (tokens)
3637
{
3738
for (var i = tokens.length - 1, token; token = tokens[i]; i--)
3839
{
39-
if (token[TYPE] == PUNCTUATOR && token[VALUE] == punctuator)
40+
if (token[TYPE] == token_type && token[VALUE] == token_value)
4041
{
41-
for (var j = 0, index = 0; j < i; j++)
42+
for (var j = 0, index = 0; j <= i; j++)
4243
index += tokens[j][VALUE].length;
4344
return index;
4445
}
@@ -66,18 +67,19 @@ window.cls.PropertyFinder = function(rt_id) {
6667
tokens.push([token_type, token]);
6768
});
6869

69-
var last_bracket = this._get_last_punctuator(tokens, '[');
70-
var last_brace = this._get_last_punctuator(tokens, '(');
70+
var last_bracket = this._get_last_token(tokens, PUNCTUATOR, '[');
71+
var last_brace = this._get_last_token(tokens, PUNCTUATOR, '(');
7172

72-
last_brace = this._get_last_punctuator(tokens, ')') <= last_brace
73+
last_brace = this._get_last_token(tokens, PUNCTUATOR, ')') <= last_brace
7374
? last_brace
7475
: -1;
75-
last_bracket = this._get_last_punctuator(tokens, ']') <= last_bracket
76+
last_bracket = this._get_last_token(tokens, PUNCTUATOR, ']') <= last_bracket
7677
? last_bracket
7778
: -1;
7879
input = input.slice(Math.max(last_brace,
7980
last_bracket,
80-
this._get_last_punctuator(tokens, '=')) + 1);
81+
this._get_last_token(tokens, PUNCTUATOR, '='),
82+
this._get_last_token(tokens, IDENTIFIER, 'in')));
8183
input = input.replace(/^\s+/, '');
8284

8385
var last_dot = input.lastIndexOf('.');

0 commit comments

Comments
 (0)