diff --git a/VoiceInk/CursorPaster.swift b/VoiceInk/CursorPaster.swift index 9ce08bb..2fa7333 100644 --- a/VoiceInk/CursorPaster.swift +++ b/VoiceInk/CursorPaster.swift @@ -9,14 +9,12 @@ class CursorPaster { var savedContents: [(NSPasteboard.PasteboardType, Data)] = [] - if shouldPreserveClipboard { - let currentItems = pasteboard.pasteboardItems ?? [] - - for item in currentItems { - for type in item.types { - if let data = item.data(forType: type) { - savedContents.append((type, data)) - } + let currentItems = pasteboard.pasteboardItems ?? [] + + for item in currentItems { + for type in item.types { + if let data = item.data(forType: type) { + savedContents.append((type, data)) } } } diff --git a/VoiceInk/Whisper/WhisperState.swift b/VoiceInk/Whisper/WhisperState.swift index 74d7ee9..d91b9be 100644 --- a/VoiceInk/Whisper/WhisperState.swift +++ b/VoiceInk/Whisper/WhisperState.swift @@ -335,10 +335,14 @@ class WhisperState: NSObject, ObservableObject { SoundManager.shared.playStopSound() DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { + let originalClipboardContent = ClipboardManager.getClipboardContent() + CursorPaster.pasteAtCursor(text, shouldPreserveClipboard: !self.isAutoCopyEnabled) - if self.isAutoCopyEnabled { - ClipboardManager.copyToClipboard(text) + if self.isAutoCopyEnabled, let originalContent = originalClipboardContent { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) { + ClipboardManager.copyToClipboard(originalContent) + } } // Automatically press Enter if the active Power Mode configuration allows it.