From cddddc57c4c7421ffdabdda5c4fa2a9ea803f090 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 12 Jul 2024 00:42:13 +0800 Subject: [PATCH] fix: wrong regex index assignment (#13) --- src/controller/immersive.ts | 5 +---- src/regex.ts | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 src/regex.ts diff --git a/src/controller/immersive.ts b/src/controller/immersive.ts index df84ca2..2e66f8b 100644 --- a/src/controller/immersive.ts +++ b/src/controller/immersive.ts @@ -2,7 +2,6 @@ import { MarkdownString, Range, commands, window, workspace } from 'vscode' import type { TextEditor } from 'vscode' import { effect, toRefs } from '@vue/reactivity' import { knownWords, onConfigUpdated } from '~/config' -import { REGEX_FIND_PHRASES } from '~/regex' import { GapLinesTextDecoration } from '~/view/Interline' import type { DecorationMatch } from '~/types' import { clearTranslationCache, useTranslationCache } from '~/model/cache' @@ -36,8 +35,6 @@ export function RegisterTranslator(ctx: Context) { const placeholderCodeLens = usePlaceholderCodeLensProvider() - const regex = REGEX_FIND_PHRASES - async function updateDecorations() { if (!editor) return @@ -56,7 +53,7 @@ export function RegisterTranslator(ctx: Context) { const tokens = await parseDocumentToTokens({ textDocument: editor.document }) - for (const { phrase, match, translated } of extractPhrases(text)) { + for (const { phrase, match, translated, regex } of extractPhrases(text)) { const translatedText = translated ? phrase : translationCache.get(phrase) diff --git a/src/regex.ts b/src/regex.ts deleted file mode 100644 index 2eba9f5..0000000 --- a/src/regex.ts +++ /dev/null @@ -1,2 +0,0 @@ -// 查找词组 -export const REGEX_FIND_PHRASES = /[\w|-]{2,}/g