feat(input): expand Araso Han/Eng contractions, acronyms, typo recovery, and fast cursor-tail replacement

This commit is contained in:
Yun Chan 2026-10-28 10:41:26 +09:00
parent 51bf664302
commit f403111256
80 changed files with 1449 additions and 458 deletions

View file

@ -99,16 +99,16 @@ describe('TypoCorrectionService', () => {
expect(fake.replaceBeforeCaret).not.toHaveBeenCalled()
})
it('비밀번호·조합 중·선택·터미널·에디터·제외 앱·클릭만 한 칸은 건드리지 않는다', () => {
it('비밀번호·조합 진행 중(짧은 유휴)·선택·터미널·제외 앱·클릭만 한 칸은 건드리지 않는다', () => {
const fake = deps()
const service = new TypoCorrectionService(fake.deps)
config.inputExcludedApps = ['notes.exe']
for (const overrides of [
{ isPassword: true },
{ isComposing: true },
{ isComposing: true, prefix: '오늘 회의는 잘 됬어', idleMs: 300 },
{ hasSelection: true },
{ appName: 'WindowsTerminal.exe' },
{ appName: 'Code.exe' },
{ terminalMode: true },
{ appName: 'notes.exe' },
{ editedSinceFocus: false },
{ caretReliable: false }
@ -118,6 +118,29 @@ describe('TypoCorrectionService', () => {
expect(fake.replaceBeforeCaret).not.toHaveBeenCalled()
})
it('사전에서 놓친 한영+오타 복합 어절(ㅗ디ㅐ, ㅡㅁ가둥 등)은 단 1어절이어도 공백 뒤 짧은 멈춤(380ms)에서 Gemma 모델로 즉시 자동 교정한다', async () => {
const generate = vi.fn(async function* () {
yield 'ㅡㅁ가둥 => markdown'
})
const fake = deps({ warmModel: () => 'gemma4:e4b', generate })
const service = new TypoCorrectionService(fake.deps)
expect(
service.handleTypingContext(
typingContext({
prefix: 'ㅡㅁ가둥 ',
isComposing: true,
idleMs: 380,
appName: 'Antigravity.exe'
})
)
).toBe('checking')
await flush()
await flush()
expect(generate).toHaveBeenCalledTimes(1)
expect(fake.replaceBeforeCaret).toHaveBeenCalledWith('ㅡㅁ가둥 '.length, 'markdown ')
})
it('설정으로 끌 수 있다', () => {
config.typoAutoCorrectEnabled = false
const fake = deps()
@ -299,6 +322,43 @@ describe('TypoCorrectionService', () => {
'dlrjs github dp commit gkf rjdi'.length,
'이건 github 에 commit 할 거야'
)
fake.replaceBeforeCaret.mockClear()
// trailingWordOnly 모드에서는 문장 앞쪽에 미변환 어절이 남아 있어도 문장 전체를 지우지 않고 커서 직전 마지막 어절만 고친다
expect(
service.handleTypingContext(
typingContext({ prefix: "dlrjs already typed long sentence and ㅊ무ㅜ'ㅅ ", idleMs: 60 }),
{ layoutOnly: true, trailingWordOnly: true }
)
).toBe('correcting')
await flush()
expect(fake.replaceBeforeCaret).toHaveBeenCalledWith("ㅊ무ㅜ'ㅅ ".length, "can't ")
fake.replaceBeforeCaret.mockClear()
// 커서 끝의 짧은 연속 교정 사슬("ㅑ ㅊ무'ㅅ ")은 함께 "I can't " 로 고치고, 지운 뒤 다시 쳐도 재교정한다
expect(
service.handleTypingContext(typingContext({ prefix: "ㅑ ㅊ무'ㅅ ", idleMs: 60 }), {
layoutOnly: true,
trailingWordOnly: true
})
).toBe('correcting')
await flush()
expect(fake.replaceBeforeCaret).toHaveBeenCalledWith("ㅑ ㅊ무'ㅅ ".length, "I can't ")
// 지워서 다른 구간이 되었다가 다시 "ㅑ ㅊ무'ㅅ " 를 치면 다시 교정된다
fake.replaceBeforeCaret.mockClear()
service.handleTypingContext(typingContext({ prefix: 'ㅑ ', idleMs: 10 }), {
layoutOnly: true,
trailingWordOnly: true
})
expect(
service.handleTypingContext(typingContext({ prefix: "ㅑ ㅊ무'ㅅ ", idleMs: 60 }), {
layoutOnly: true,
trailingWordOnly: true
})
).toBe('correcting')
await flush()
expect(fake.replaceBeforeCaret).toHaveBeenCalledWith("ㅑ ㅊ무'ㅅ ".length, "I can't ")
})
it('Discord/Chromium 처럼 comp=true 가 계속 켜져 있거나 스페이스 직후 짧은 유휴(60ms)여도 한영 전환은 즉시 교정한다', async () => {