diff --git a/TwitchDownloaderWPF/Behaviors/TextBoxTripleClickBehavior.cs b/TwitchDownloaderWPF/Behaviors/TextBoxTripleClickBehavior.cs index d4f097be..77c9d880 100644 --- a/TwitchDownloaderWPF/Behaviors/TextBoxTripleClickBehavior.cs +++ b/TwitchDownloaderWPF/Behaviors/TextBoxTripleClickBehavior.cs @@ -41,8 +41,15 @@ private static (int start, int length) GetCurrentLine(TextBox textBox) var caretPos = textBox.CaretIndex; var text = textBox.Text; - var start = text.LastIndexOf('\n', caretPos, caretPos); - var end = text.IndexOf('\n', caretPos); + var start = -1; + var end = -1; + + // CaretIndex can be negative for some reason. + if (caretPos >= 0) + { + start = text.LastIndexOf('\n', caretPos, caretPos); + end = text.IndexOf('\n', caretPos); + } if (start == -1) {