Notepad++ Plugin GetText Method Not Getting Entire String In C#
Good evening,
After doing some debugging and troubleshooting, I found a solution that is to replace the size of the textBuffer variable from a static value 10000 to the actual length passed into the function parameter.
Since the length is set using the ScintillaGateway GetLength() function.
Output
Cheers!
We have this Notepad++ Plugin project that will read and parse an html document converted from a MS Word file and then change the html string into an Adobe In Design format. The issue is that the html document has over 20,000 plus lines even reaching 40,000 lines or more. The code below will get all the text from an active Notepad++ window but fails if the string content is huge.
public unsafe string GetText(int length) { byte[] textBuffer = new byte[10000]; fixed (byte* textPtr = textBuffer) { Win32.SendMessage(scintilla, SciMsg.SCI_GETTEXT, (IntPtr)length, (IntPtr)textPtr); return Encoding.UTF8.GetString(textBuffer).TrimEnd('\0'); } }
public unsafe string GetText(int length) { byte[] textBuffer = new byte[length]; fixed (byte* textPtr = textBuffer) { Win32.SendMessage(scintilla, SciMsg.SCI_GETTEXT, (IntPtr)length, (IntPtr)textPtr); return Encoding.UTF8.GetString(textBuffer).TrimEnd('\0'); } }
length = scintillaGateway.GetLength(); supplementAllText = scintillaGateway.GetText(length + 1);
Cheers!
Comments
Post a Comment