Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 5ee9c68

Browse files
committed
bugfix GetSelectionLength - now return 1 less due to \0 handling
1 parent 808c805 commit 5ee9c68

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Visual Studio Project Template C#/PluginInfrastructure/ScintillaGateway.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ public class ScintillaGateway : IScintillaGateway
2525

2626
private readonly IntPtr scintilla;
2727

28+
public static readonly int LengthZeroTerminator = "\0".Length;
29+
30+
2831
public ScintillaGateway(IntPtr scintilla)
2932
{
3033
this.scintilla = scintilla;
3134
}
3235

3336
public int GetSelectionLength()
3437
{
35-
var selectionLength = (int)Win32.SendMessage(scintilla, SciMsg.SCI_GETSELTEXT, Unused, Unused);
38+
var selectionLength = (int) Win32.SendMessage(scintilla, SciMsg.SCI_GETSELTEXT, Unused, Unused) - LengthZeroTerminator;
3639
return selectionLength;
3740
}
3841

0 commit comments

Comments
 (0)