From ff5e8dc3f54684937f28eb4ba4814efd692f488d Mon Sep 17 00:00:00 2001 From: Fedor Indutny <238531+indutny@users.noreply.github.com> Date: Fri, 24 Nov 2023 10:05:23 -0800 Subject: [PATCH] Fix repl autocompletion for regexp with flags Fix: #74 --- repl.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repl.js b/repl.js index cc83489..492f158 100644 --- a/repl.js +++ b/repl.js @@ -583,6 +583,9 @@ import * as os from "os"; base = get_context_word(line, pos); if (["true", "false", "null", "this"].includes(base) || !isNaN(+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); if (obj === null || obj === void 0) return obj;