@@ -437,9 +437,7 @@ CString GetSelectedFunction (CString & strWindowContents, int & nStartChar, int
437
437
438
438
if (nStartChar == nEndChar)
439
439
{
440
- // if at end-of-file, go back a character
441
- // if (nStartChar >= strWindowContents.GetLength ())
442
- nStartChar--;
440
+ nStartChar--; // go back one so we are not at end of string
443
441
444
442
// scan backwards from cursor
445
443
while (nStartChar >= 0 &&
@@ -510,10 +508,38 @@ CString GetSelectedFunction (CString & strWindowContents, int & nStartChar, int
510
508
511
509
} // end of GetSelectedFunction
512
510
513
- void ShowFunctionslist (CString & strSelection , int nStartChar, int nEndChar, const bool bLua)
511
+ void ShowFunctionslist (CString & strWindowContents , int nStartChar, int nEndChar, const bool bLua)
514
512
{
515
513
516
- CString strWord = GetSelectedFunction (strSelection, nStartChar, nEndChar);
514
+ // skip backwards over any whitespace or LH brackets (which the new
515
+ // function context stuff probably put there)
516
+
517
+ if (!strWindowContents.IsEmpty ())
518
+ {
519
+
520
+ if (nStartChar == nEndChar)
521
+ {
522
+ nStartChar--; // error if at end of string, so go back one
523
+ nEndChar--;
524
+
525
+ // scan backwards from cursor
526
+ while (nStartChar >= 0 &&
527
+ (isspace (strWindowContents [nStartChar]) ||
528
+ strWindowContents [nStartChar] == ' (' )
529
+ )
530
+ {
531
+ nStartChar--;
532
+ nEndChar--;
533
+ }
534
+
535
+ } // no selection
536
+ nStartChar++; // compensate for earlier subtract
537
+ nEndChar++;
538
+
539
+ } // end of some contents
540
+
541
+
542
+ CString strWord = GetSelectedFunction (strWindowContents, nStartChar, nEndChar);
517
543
518
544
CFunctionListDlg dlg;
519
545
0 commit comments