@@ -89,7 +89,7 @@ public void AppendFiles(IEnumerable<string> paths)
8989 ProduceStringArrays ( ) ;
9090 }
9191
92- private void ProduceStringArrays ( int caret = - 1 , string text = "" )
92+ private void ProduceStringArrays ( int caret = - 1 , List < SMFunction > currentFunctions = null )
9393 {
9494 FunctionStrings = new string [ Functions . Count ] ;
9595 for ( var i = 0 ; i < Functions . Count ; ++ i ) FunctionStrings [ i ] = Functions [ i ] . Name ;
@@ -127,9 +127,11 @@ private void ProduceStringArrays(int caret = -1, string text = "")
127127 constantNames . AddRange ( Defines . Select ( i => i . Name ) ) ;
128128 constantNames . AddRange ( Variables . Select ( v => v . Name ) ) ;
129129
130- if ( caret != - 1 )
130+ if ( caret != - 1 && currentFunctions != null )
131131 {
132- var currentFunc = Functions . FirstOrDefault ( e => e . Index < caret && caret <= e . EndPos && e . File . EndsWith ( ".sp" ) ) ;
132+ // TODO: This somewhat works, but somethings when in the end of a function it's buggy and doesnt find
133+ // the correct function or it finds nothing at all. The addition is a small hack that sometimes works
134+ var currentFunc = currentFunctions . FirstOrDefault ( e => e . Index < caret && caret <= e . EndPos + 5 && e . File . EndsWith ( ".sp" ) ) ;
133135 if ( currentFunc != null )
134136 {
135137
@@ -203,7 +205,7 @@ public void MergeDefinitions(SMDefinition def)
203205 }
204206 }
205207
206- public SMDefinition ProduceTemporaryExpandedDefinition ( SMDefinition [ ] definitions , int caret , string text )
208+ public SMDefinition ProduceTemporaryExpandedDefinition ( SMDefinition [ ] definitions , int caret , List < SMFunction > currentFunctions )
207209 {
208210 var def = new SMDefinition ( ) ;
209211 def . MergeDefinitions ( this ) ;
@@ -212,7 +214,7 @@ public SMDefinition ProduceTemporaryExpandedDefinition(SMDefinition[] definition
212214 def . MergeDefinitions ( definition ) ;
213215
214216 def . Sort ( ) ;
215- def . ProduceStringArrays ( caret , text ) ;
217+ def . ProduceStringArrays ( caret , currentFunctions ) ;
216218 return def ;
217219 }
218220
0 commit comments