fix(suggestion): keep a shown typo fix when only trailing spaces changed before accepting

The session ignores trailing whitespace but acceptance compared the raw
prefix, so typing one more space after the fix appeared made accept drop
the correction silently and leave the typo in place.
This commit is contained in:
Yun Chan 2026-10-20 16:27:40 +09:00
parent 1b39afe9ff
commit 32cf826290
3 changed files with 45 additions and 1 deletions

View file

@ -44,6 +44,7 @@ import {
import { renderRawChatPrompt, rawChatStopSequences } from '@d3ro/core/chat-template'
import { buildQueryTerms, splitSentences } from '@d3ro/core/personal-graph'
import { analyzeWritingContext, findUnsupportedFacts } from '@d3ro/core/writing-context'
import { alignCorrectionToPrefix } from '@d3ro/core/typo-correction'
import { configGet, configSet } from './ConfigService'
import { getLogger } from './LoggerService'
import { getLocalLLMService } from './LocalLLMService'
@ -1920,7 +1921,7 @@ export class SuggestionService extends EventEmitter {
// 교정이 있으면 커서 앞 오타 구간을 지우고 고친 글 + 후보를 함께 넣는다. 그사이 원문 끝이 달라졌으면
// (IME 마지막 글자 교체 등) 교정은 버리고 후보만 넣는다 — 엉뚱한 글자를 지우지 않는다.
const acceptPrefix = this._acceptPrefix()
const correction = this._correction && acceptPrefix.endsWith(this._correction.from) ? this._correction : null
const correction = this._correction ? alignCorrectionToPrefix(acceptPrefix, this._correction) : null
const basePrefix = correction
? acceptPrefix.slice(0, acceptPrefix.length - correction.from.length) + correction.to
: acceptPrefix