Skip to content

Commit 97b4967

Browse files
committed
- #74: Intellisense not working as expected
- The default of `AutoSelectFirstSuggestion` to true. To make it consistent with VS. It can always be changed in the config file.
1 parent 100162a commit 97b4967

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/CSScriptIntellisense/CSharpIntellisense/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public string GetFileName()
5353
public bool AutoSuggestOnOpenEndLine = false;
5454
public bool FormatOnSave = false;
5555
public bool AutoInsertSingeSuggestion = false;
56-
public bool AutoSelectFirstSuggestion = false;
56+
public bool AutoSelectFirstSuggestion = true;
5757
public bool VbSupportEnabled = true;
5858
public bool FormatAsYouType = true;
5959
public string DefaultRefAsms = "System.Linq|System.Xml|System.Xml.Linq|System.Windows.Forms|System.Drawing|System.Core|Microsoft.CSharp";

src/CSScriptNpp/Interop/UnmanagedExports.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System;
22
using System.IO;
3+
using System.Linq;
34
using System.Reflection;
45
using System.Runtime.InteropServices;
56
using System.Windows.Forms;
7+
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
8+
using System.Xml.Linq;
69
using CSScriptIntellisense;
710
using Kbg.NppPluginNET;
811
using Kbg.NppPluginNET.PluginInfrastructure;
@@ -129,7 +132,25 @@ public void beNotified(IntPtr notifyCode)
129132
}
130133
else if (nc.Header.Code == (uint)SciMsg.SCN_CHARADDED)
131134
{
132-
CSScriptIntellisense.Plugin.OnCharTyped(nc.Character);
135+
if (nc.character == 0)
136+
{
137+
// There is a defect either in Scintilla or in Npp that prevents correct SciMsg.SCN_CHARADDED
138+
// notification, which leads to `nc.character` being set to zero. Detected in v8.6.2 Npp.
139+
// So extract the character from side of the caret.
140+
// This is only a work around as any direct solution is problematic since it is a Scintilla
141+
// change in behavior.
142+
143+
var document = Npp.GetCurrentDocument();
144+
var caret = document.GetCurrentPos();
145+
146+
if (caret > 0)
147+
{
148+
string textOnLeft = document.GetTextBetween(caret - 1, caret);
149+
CSScriptIntellisense.Plugin.OnCharTyped(textOnLeft.LastOrDefault());
150+
}
151+
}
152+
else
153+
CSScriptIntellisense.Plugin.OnCharTyped(nc.Character);
133154
}
134155
else if (nc.Header.Code == (uint)SciMsg.SCN_DWELLSTART) //tooltip
135156
{

0 commit comments

Comments
 (0)