@@ -1257,22 +1257,45 @@ static private bool HandleDeclarationCompletion(ScintillaControl Sci, string tai
1257
1257
return true ;
1258
1258
}
1259
1259
1260
+ /// <summary>
1261
+ /// Lookup type declaration keywords anywhere in the provided text
1262
+ /// </summary>
1260
1263
private static bool IsTypeDecl ( string line , string [ ] typesKeywords )
1261
1264
{
1265
+ var max = line . Length - 1 ;
1262
1266
foreach ( string keyword in typesKeywords )
1263
- if ( line . IndexOf ( keyword ) >= 0 ) return true ;
1267
+ {
1268
+ var p = line . IndexOf ( keyword ) ;
1269
+ if ( p >= 0 )
1270
+ {
1271
+ // verify keyword between spaces
1272
+ var end = p + keyword . Length ;
1273
+ if ( ( p == 0 || line [ p - 1 ] <= 32 )
1274
+ && end < max && line [ end ] <= 32 ) return true ;
1275
+ }
1276
+ }
1264
1277
return false ;
1265
1278
}
1266
1279
1280
+ /// <summary>
1281
+ /// Look if the provided text starts with any declaration keyword
1282
+ /// </summary>
1267
1283
private static bool IsDeclaration ( string line , ContextFeatures features )
1268
1284
{
1269
1285
foreach ( string keyword in features . accessKeywords )
1270
- if ( line . StartsWith ( keyword ) ) return true ;
1286
+ if ( line . StartsWith ( keyword ) && SpaceFollows ( line , keyword ) ) return true ;
1271
1287
foreach ( string keyword in features . declKeywords )
1272
- if ( line . StartsWith ( keyword ) ) return true ;
1288
+ if ( line . StartsWith ( keyword ) && SpaceFollows ( line , keyword ) ) return true ;
1273
1289
return false ;
1274
1290
}
1275
1291
1292
+ private static bool SpaceFollows ( string line , string keyword )
1293
+ {
1294
+ var len = keyword . Length ;
1295
+ if ( line . Length > len ) return line [ len ] <= 32 ;
1296
+ else return true ;
1297
+ }
1298
+
1276
1299
#endregion
1277
1300
1278
1301
#region function_completion
0 commit comments