From 27e08064af8ced6aaecff167f0706a2b2dc22873 Mon Sep 17 00:00:00 2001 From: Infi Date: Wed, 10 Apr 2024 21:48:43 +0200 Subject: [PATCH] Adjust CursorPos to respect UTF symbols as one and not separate entities --- ChatTwo/Ui/ChatLogWindow.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index 9569432..493da0e 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -1290,10 +1290,14 @@ public sealed class ChatLogWindow : Window, IUiComponent { } } + var start = ptr.Buf + white + 1; + var end = ptr.CursorPos - white - 1; + var utf8Message = Marshal.PtrToStringUTF8(start, end); + var correctedCursor = ptr.CursorPos - (end - utf8Message.Length); _autoCompleteInfo = new AutoCompleteInfo( - Marshal.PtrToStringUTF8(ptr.Buf + white + 1, ptr.CursorPos - white - 1), + utf8Message, white + 1, - ptr.CursorPos + correctedCursor ); _autoCompleteOpen = true; _autoCompleteSelection = 0;