From d4818e8d28f2f22098100bac61b4542a70fdb3bd Mon Sep 17 00:00:00 2001 From: JieXu Date: Sat, 27 Sep 2025 19:53:48 +0800 Subject: [PATCH] Update MsgView.axaml.cs --- v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs index 1f7665ca..b1bafa75 100644 --- a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs @@ -58,7 +58,15 @@ public partial class MsgView : ReactiveUserControl ClearMsg(); } - txtMsg.AppendText(msg.ToString()); + var s = msg?.ToString() ?? string.Empty; + s = s.TrimEnd('\r', '\n'); + if (txtMsg.Document.TextLength > 0) + { + var last = txtMsg.Document.GetText(txtMsg.Document.TextLength - 1, 1); + if (last != "\n") + txtMsg.AppendText("\n"); + } + txtMsg.AppendText(s); if (togScrollToEnd.IsChecked ?? true) { txtMsg.ScrollToEnd(); @@ -68,7 +76,7 @@ public partial class MsgView : ReactiveUserControl public void ClearMsg() { txtMsg.Clear(); - txtMsg.AppendText("----- Message cleared -----\n"); + txtMsg.AppendText("----- Message cleared -----"); } private void menuMsgViewSelectAll_Click(object? sender, RoutedEventArgs e)