diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index a010398f..7e93b30b 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -171,24 +171,24 @@ private bool CopyText(string text) bool mergeTexts = false; string? subsequentText = null; - if (ConfigManager.MergeSequentialTextsWhenTheyMatch) + Dispatcher.Invoke(() => { - DateTime preciseTimeNow = new(Stopwatch.GetTimestamp()); + if (ConfigManager.MergeSequentialTextsWhenTheyMatch) + { + DateTime preciseTimeNow = new(Stopwatch.GetTimestamp()); - mergeTexts = (ConfigManager.MaxDelayBetweenCopiesForMergingMatchingSequentialTextsInMilliseconds is 0 - || (preciseTimeNow - s_lastTextCopyTime).TotalMilliseconds < ConfigManager.MaxDelayBetweenCopiesForMergingMatchingSequentialTextsInMilliseconds) - && sanitizedText.StartsWith(MainTextBox.Text, StringComparison.Ordinal); + mergeTexts = (ConfigManager.MaxDelayBetweenCopiesForMergingMatchingSequentialTextsInMilliseconds is 0 + || (preciseTimeNow - s_lastTextCopyTime).TotalMilliseconds < ConfigManager.MaxDelayBetweenCopiesForMergingMatchingSequentialTextsInMilliseconds) + && sanitizedText.StartsWith(MainTextBox.Text, StringComparison.Ordinal); - s_lastTextCopyTime = preciseTimeNow; + s_lastTextCopyTime = preciseTimeNow; - if (mergeTexts) - { - subsequentText = sanitizedText[MainTextBox.Text.Length..]; + if (mergeTexts) + { + subsequentText = sanitizedText[MainTextBox.Text.Length..]; + } } - } - Dispatcher.Invoke(() => - { if (mergeTexts) { MainTextBox.AppendText(subsequentText);