From a9e1a3002ea90e7b7a5a1f1c8154aca8bf56a99a Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Mon, 8 Aug 2022 17:53:16 +0600 Subject: [PATCH] Hightlight environment variable with a dash '-' in its name (#2560) --- .../helpers/editor/extensions/HoppEnvironment.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/hoppscotch-app/helpers/editor/extensions/HoppEnvironment.ts b/packages/hoppscotch-app/helpers/editor/extensions/HoppEnvironment.ts index 6111a560f..020b3f18f 100644 --- a/packages/hoppscotch-app/helpers/editor/extensions/HoppEnvironment.ts +++ b/packages/hoppscotch-app/helpers/editor/extensions/HoppEnvironment.ts @@ -16,7 +16,7 @@ import { getAggregateEnvs, } from "~/newstore/environments" -const HOPP_ENVIRONMENT_REGEX = /(<<\w+>>)/g +const HOPP_ENVIRONMENT_REGEX = /(<<[a-zA-Z0-9-_]+>>)/g const HOPP_ENV_HIGHLIGHT = "cursor-help transition rounded px-1 focus:outline-none mx-0.5 env-highlight" @@ -44,8 +44,9 @@ const cursorTooltipField = (aggregateEnvs: AggregateEnvironment[]) => let start = pos let end = pos - while (start > from && /\w/.test(text[start - from - 1])) start-- - while (end < to && /\w/.test(text[end - from])) end++ + while (start > from && /[a-zA-Z0-9-_]+/.test(text[start - from - 1])) + start-- + while (end < to && /[a-zA-Z0-9-_]+/.test(text[end - from])) end++ if ( (start === pos && side < 0) ||