fix(screen-context): skip selected-text capture when the clipboard can't be fully restored

Capture still used the old snapshot code: a file copied in Explorer looked
empty and was cleared, and Excel's own formats were dropped on restore. It
now uses the shared clipboard snapshot policy and leaves the clipboard
alone when it couldn't put everything back.
This commit is contained in:
Yun Chan 2026-10-20 22:51:51 +09:00
parent 9d0548f871
commit 95656b098a
3 changed files with 31 additions and 55 deletions

View file

@ -67,4 +67,15 @@ describe('ScreenContextService.captureSelectedText', () => {
image,
})
})
it('탐색기에서 복사한 파일처럼 되돌릴 수 없는 클립보드면 캡처를 건너뛰고 클립보드를 건드리지 않는다', async () => {
vi.mocked(clipboard.availableFormats).mockReturnValueOnce(['FileNameW'])
const text = await getScreenContextService().captureSelectedText()
expect(text).toBeNull()
expect(nut.pressKey).not.toHaveBeenCalled()
expect(clipboardClear).not.toHaveBeenCalled()
expect(clipboard.write).not.toHaveBeenCalled()
})
})

View file

@ -65,6 +65,9 @@ vi.mock('electron', () => ({
readHTML: vi.fn(() => ''),
readRTF: vi.fn(() => ''),
readImage: vi.fn(() => ({ isEmpty: () => true, toPNG: () => Buffer.alloc(0) })),
availableFormats: vi.fn((): string[] => []),
readBuffer: vi.fn(() => Buffer.alloc(0)),
writeBuffer: vi.fn(),
write: vi.fn(),
},
shell: {