Skip to content

Commit 5d5764c

Browse files
committed
Allowed for brackets when doing function list help
1 parent 722dbb9 commit 5d5764c

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

scripting/functionlist.cpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,7 @@ CString GetSelectedFunction (CString & strWindowContents, int & nStartChar, int
437437

438438
if (nStartChar == nEndChar)
439439
{
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
443441

444442
// scan backwards from cursor
445443
while (nStartChar >= 0 &&
@@ -510,10 +508,38 @@ CString GetSelectedFunction (CString & strWindowContents, int & nStartChar, int
510508

511509
} // end of GetSelectedFunction
512510

513-
void ShowFunctionslist (CString & strSelection, int nStartChar, int nEndChar, const bool bLua)
511+
void ShowFunctionslist (CString & strWindowContents, int nStartChar, int nEndChar, const bool bLua)
514512
{
515513

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);
517543

518544
CFunctionListDlg dlg;
519545

0 commit comments

Comments
 (0)