From 2db02417569654e95f529de28e0bbb3a3f54d291 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 31 May 2024 16:30:33 -0700 Subject: [PATCH] Stream chinese text in chat character-by-character Fix #213287 --- src/vs/workbench/contrib/chat/common/chatWordCounter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/chat/common/chatWordCounter.ts b/src/vs/workbench/contrib/chat/common/chatWordCounter.ts index 9487029616055..c3b7ff8822c53 100644 --- a/src/vs/workbench/contrib/chat/common/chatWordCounter.ts +++ b/src/vs/workbench/contrib/chat/common/chatWordCounter.ts @@ -11,7 +11,7 @@ export interface IWordCountResult { export function getNWords(str: string, numWordsToCount: number): IWordCountResult { // Match words and markdown style links - const allWordMatches = Array.from(str.matchAll(/\[([^\]]+)\]\(([^)]+)\)|[^\s\|\-]+/g)); + const allWordMatches = Array.from(str.matchAll(/\[([^\]]+)\]\(([^)]+)\)|\p{sc=Han}|[^\s\|\-|\p{sc=Han}]+/gu)); const targetWords = allWordMatches.slice(0, numWordsToCount);