Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions PSReadLine/Completion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ public void UpdateMenuSelection(int selectedItem, bool select, bool showTooltips
// Determine if showing the tooltip would scroll the top of our buffer off the screen.

int lineLength = 0;
bool fullLine = false;
for (var i = 0; i < toolTip.Length; i++)
{
char c = toolTip[i];
Expand All @@ -572,8 +573,13 @@ public void UpdateMenuSelection(int selectedItem, bool select, bool showTooltips

if (c == '\r' || c == '\n')
{
toolTipLines += 1;
lineLength = 0;
// If we happened to have a full line right before the newline character, then we
// skip this newline character because we already increased the line count.
if (!fullLine)
{
toolTipLines += 1;
lineLength = 0;
}
}
else
{
Expand All @@ -582,8 +588,14 @@ public void UpdateMenuSelection(int selectedItem, bool select, bool showTooltips
{
toolTipLines += 1;
lineLength = 0;

// Indicate that we just had a full line.
fullLine = true;
continue;
}
}

fullLine = false;
}

// The +1 is for the blank line between the menu and tooltips.
Expand Down