Fix repl autocompletion for regexp with flags

Fix: #74
This commit is contained in:
Fedor Indutny 2023-11-24 10:05:23 -08:00 committed by Saúl Ibarra Corretgé
parent 463df3adf6
commit ff5e8dc3f5

View file

@ -583,6 +583,9 @@ import * as os from "os";
base = get_context_word(line, pos); base = get_context_word(line, pos);
if (["true", "false", "null", "this"].includes(base) || !isNaN(+base)) if (["true", "false", "null", "this"].includes(base) || !isNaN(+base))
return eval(base); return eval(base);
// Check if `base` is a set of regexp flags
if (pos - base.length >= 3 && line[pos - base.length - 1] === '/')
return new RegExp('', base);
obj = get_context_object(line, pos - base.length); obj = get_context_object(line, pos - base.length);
if (obj === null || obj === void 0) if (obj === null || obj === void 0)
return obj; return obj;