Skip to content

Commit c0af6a1

Browse files
committed
Restore support for new multiple lines in argument descriptions
1 parent 4468898 commit c0af6a1

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

Source/ExcelDna.IntelliSense.Host/MyFunctions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public class MyFunctions
1313
HelpTopic = "http://www.google.com")]
1414
public static double AddThem(
1515
[ExcelArgument(Name = "Augend", Description = "is the first number, to which will be added")] double v1,
16-
[ExcelArgument(Name = "Addend", Description = "is the second number that will be added")] double v2)
17-
{
18-
return v1 + v2;
16+
[ExcelArgument(Name = "Addend", Description = "is the second number that will be added\r\nin other words, and another line,\r\nthe extra stuff")] double v2)
17+
{
18+
return v1 + v2;
1919
}
2020

2121
[ExcelFunction(Description = "--------------------",

Source/ExcelDna.IntelliSense/IntelliSenseDisplay.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void FunctionListSelectedItemChange(string selectedItemText, Rect selectedItemBo
424424
try
425425
{
426426
_descriptionToolTip?.ShowToolTip(
427-
text: new FormattedText { GetFunctionDescriptionOrNull(functionInfo) },
427+
text: new FormattedText { descriptionLines },
428428
linePrefix: null,
429429
left: (int)listBounds.Right + DescriptionLeftMargin,
430430
top: (int)selectedItemBounds.Bottom - 18,
@@ -531,9 +531,8 @@ FormattedText GetFunctionIntelliSense(FunctionInfo functionInfo, int currentArgI
531531
var formattedText = new FormattedText { nameLine, descriptionLines };
532532
if (argumentList.Count > currentArgIndex)
533533
{
534-
var description = GetArgumentDescriptionOrNull(argumentList[currentArgIndex]);
535-
if (description != null)
536-
formattedText.Add(description);
534+
var description = GetArgumentDescription(argumentList[currentArgIndex]);
535+
formattedText.Add(description);
537536
}
538537

539538
return formattedText;
@@ -583,12 +582,13 @@ FormattedText GetFunctionIntelliSense(FunctionInfo functionInfo, int currentArgI
583582
}
584583
}
585584

586-
TextLine GetArgumentDescriptionOrNull(FunctionInfo.ArgumentInfo argumentInfo)
585+
IEnumerable<TextLine> GetArgumentDescription(FunctionInfo.ArgumentInfo argumentInfo)
587586
{
588587
if (string.IsNullOrEmpty(argumentInfo.Description))
589-
return null;
588+
yield break;
590589

591-
return new TextLine {
590+
var lines = argumentInfo.Description.Split(s_newLineStringArray, StringSplitOptions.None);
591+
yield return new TextLine {
592592
new TextRun
593593
{
594594
Style = System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic,
@@ -597,9 +597,19 @@ TextLine GetArgumentDescriptionOrNull(FunctionInfo.ArgumentInfo argumentInfo)
597597
new TextRun
598598
{
599599
Style = System.Drawing.FontStyle.Italic,
600-
Text = argumentInfo.Description ?? ""
600+
Text = lines.FirstOrDefault() ?? ""
601601
},
602602
};
603+
604+
foreach (var line in lines.Skip(1))
605+
{
606+
yield return new TextLine {
607+
new TextRun
608+
{
609+
Style = System.Drawing.FontStyle.Italic,
610+
Text = line
611+
}};
612+
}
603613
}
604614

605615
public void Dispose()

0 commit comments

Comments
 (0)