Skip to content

Commit ec9e40f

Browse files
committed
Keep it simple
1 parent 3613c22 commit ec9e40f

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

PasteIntoFile/Dialog.cs

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -286,47 +286,25 @@ private bool readClipboard() {
286286

287287

288288
private void ClipboardChanged(Object sender, SharpClipboard.ClipboardChangedEventArgs e) {
289+
// Only process update if live update enabled, or in batch mode
290+
if (!chkEnableLiveClipboardUpdate.Checked && !chkContinuousMode.Checked) return;
291+
289292
var previousClipboardTimestamp = clipData.Timestamp;
290-
291-
// Peek at new clipboard data to get timestamp (without updating UI)
292-
var newClipData = ClipboardContents.FromClipboard();
293-
294-
// Determine if we should update the UI
295-
bool shouldUpdateUI = false;
296-
bool shouldSave = false;
297-
293+
readClipboard();
294+
295+
// continuous batch mode
298296
if (chkContinuousMode.Checked) {
299-
// Batch mode: always update UI and save when clipboard changes
300-
// (regardless of live update setting, since batch mode needs to show progress)
301297
var ignore = false;
302-
// ignore duplicate updates within 500ms
303-
ignore |= (newClipData.Timestamp - previousClipboardTimestamp).TotalMilliseconds <= 500;
298+
// ignore duplicate updates within 100ms
299+
ignore |= (clipData.Timestamp - previousClipboardTimestamp).TotalMilliseconds <= 500;
304300
// ignore internal updates due to clipboard patching
305301
ignore |= Clipboard.ContainsData(Program.PATCHED_CLIPBOARD_MAGIC);
306302

307303
if (!ignore) {
308-
shouldUpdateUI = true;
309-
shouldSave = true;
310-
}
311-
} else if (chkEnableLiveClipboardUpdate.Checked) {
312-
// Normal mode: update UI only if live updates are enabled
313-
shouldUpdateUI = true;
314-
}
315-
316-
// Read clipboard and update UI if needed
317-
if (shouldUpdateUI) {
318-
readClipboard();
319-
// In batch mode with append, don't update filename to preserve user's choice
320-
if (!chkContinuousMode.Checked || !chkAppend.Checked) {
321-
updateFilename();
304+
if (!chkAppend.Checked) updateFilename();
305+
save();
322306
}
323307
}
324-
325-
// Save in batch mode
326-
if (shouldSave) {
327-
save();
328-
updateSavebutton();
329-
}
330308
}
331309

332310

0 commit comments

Comments
 (0)