fix(desktop): prevent fast correction input races

This commit is contained in:
Yun Chan 2026-11-04 07:06:10 +09:00
parent 5ec063c744
commit 21a684d572
12 changed files with 134 additions and 18 deletions

View file

@ -25,6 +25,8 @@ import {
interface Internal {
_handleKeyDown(event: { keycode: number; ctrlKey: boolean; altKey: boolean; metaKey: boolean; shiftKey: boolean }): void
_scheduleTextSnapshot(keyClass?: 'letter' | 'space'): void
_captureTextSnapshot: () => Promise<null>
_lastTypedAt: number
}
@ -53,4 +55,25 @@ describe('IME 글자 키', () => {
service._handleKeyDown(key(0))
expect(service._lastTypedAt).toBe(0)
})
it('단어 경계 교정 스냅샷은 140ms 동안 추가 입력이 없을 때만 실행한다', () => {
vi.useFakeTimers()
try {
const service = getInputTelemetryService() as unknown as Internal
const capture = vi.fn(async () => null)
service._captureTextSnapshot = capture
service._scheduleTextSnapshot('space')
vi.advanceTimersByTime(139)
service._scheduleTextSnapshot('letter')
vi.advanceTimersByTime(1)
expect(capture).not.toHaveBeenCalled()
service._scheduleTextSnapshot('space')
vi.advanceTimersByTime(140)
expect(capture).toHaveBeenCalledTimes(1)
} finally {
vi.useRealTimers()
}
})
})