Stream chinese text in chat character-by-character (#214046)

Fix #213287
This commit is contained in:
Rob Lourens 2024-05-31 23:28:07 -07:00 committed by GitHub
parent e0e011ce60
commit fca05df7d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);