Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 8720f08

Browse files
committed
disable autocomplete force when selecting text
1 parent 6f69691 commit 8720f08

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

UI/Components/EditorElement/EditorElementIntellisenseController.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,38 @@ namespace SPCode.UI.Components
1717
{
1818
enum ACType
1919
{
20+
/// <summary>
2021
/// Top level objects, such as Functions, Variables, Types.
22+
/// </summary>
2123
Toplevel,
22-
24+
25+
/// <summary>
2326
/// Class Methods and Fields. Also used for MethodMap list.
27+
/// </summary>
2428
Class,
2529

26-
/// Pre-processor statments.
30+
/// <summary>
31+
/// Pre-processor statements.
32+
/// </summary>
2733
PreProc,
2834
}
2935

30-
/// @note
3136
// AC stands for AutoComplete
3237
// IS stands for IntelliSense and is often replaced with "Doc"/"Documentation"
3338
//
3439
// _smDef is the SMDefinition that contains all the symbols of the include directory and open file,
3540
// currentSmDef contains only the current file symbols.
41+
3642
public partial class EditorElement
3743
{
3844
private bool _isAcOpen;
3945
private List<ACNode> _acEntries;
4046

41-
/// We use this just to keep track of the current isNodes for the equality check.
42-
/// Seems like that using this as ItemsSource for the MethodAutoCompleteBox causes it to not update the UI
47+
/// <summary>
48+
/// We use this just to keep track of the current isNodes for the equality check. <br></br>
49+
/// Seems like that using this as ItemsSource for the MethodAutoCompleteBox causes it to not update the UI <br></br>
4350
/// when ScrollIntoView is called.
51+
/// </summary>
4452
private readonly List<ACNode> _methodACEntries = new();
4553

4654
private bool _isDocOpen;
@@ -61,12 +69,16 @@ public partial class EditorElement
6169

6270
static private readonly SMDefinition.ISNodeEqualityComparer ISEqualityComparer = new();
6371

72+
/// <summary>
6473
/// Used to keep track of the current autocomplete type (ie. toplevel, class or preprocessor)
74+
/// </summary>
6575
private ACType _acType = ACType.Toplevel;
6676

6777
private SMDefinition _smDef;
6878

79+
/// <summary>
6980
/// Matches either a function call ("PrintToChat(...)") or a method call ("arrayList.Push(...)")
81+
/// </summary>
7082
static private readonly Regex ISFindRegex = new(
7183
@"\b(((?<class>[a-zA-Z_]([a-zA-Z0-9_]?)+)\.)?(?<method>[a-zA-Z_]([a-zA-Z0-9_]?)+)\()",
7284
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
@@ -77,7 +89,9 @@ public partial class EditorElement
7789
static private readonly Regex MultilineCommentRegex = new(@"/\*.*?\*/",
7890
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline);
7991

80-
// Pre-processor statements
92+
/// <summary>
93+
/// Pre-processor statements
94+
/// </summary>
8195
static private readonly string[] PreProcArr =
8296
{
8397
"assert", "define", "else", "elseif", "endif", "endinput", "endscript", "error", "warning", "if",
@@ -92,7 +106,7 @@ static private readonly IEnumerable<ACNode>
92106
static private readonly Regex PreprocessorRegex = new("#\\w+", RegexOptions.Compiled);
93107

94108
/// <summary>
95-
/// This is called only one time when the program first opens.
109+
/// This is called only one time when the program first opens.
96110
/// </summary>
97111
public void LoadAutoCompletes()
98112
{
@@ -128,7 +142,7 @@ public void LoadAutoCompletes()
128142
}
129143

130144
/// <summary>
131-
/// This is called several times. Mostly when the caret position changes.
145+
/// This is called several times. Mostly when the caret position changes.
132146
/// </summary>
133147
/// <param name="smDef"> The SMDefinition </param>
134148
private void InterruptLoadAutoCompletes(SMDefinition smDef)
@@ -395,7 +409,7 @@ bool ComputeAutoComplete(string text, int lineOffset, int quoteCount)
395409
}
396410

397411

398-
if (text.Length == 0)
412+
if (text.Length == 0 || editor.SelectionLength > 0)
399413
return false;
400414

401415
if (!IsValidFunctionChar(text[lineOffset - 1]) &&

0 commit comments

Comments
 (0)