Browse Source

CompletionWindowBase: if window opened upwards, adjust its position when the window gets resized (e.g. due to filtering of code completion items) [based on patch by Eusebiu Marcu]

pull/1/head
Daniel Grunwald 15 years ago
parent
commit
a467999fbe
  1. 17
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs

17
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs

@ -47,6 +47,11 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
/// </summary> /// </summary>
public int EndOffset { get; set; } public int EndOffset { get; set; }
/// <summary>
/// Gets whether the window was opened above the current line.
/// </summary>
protected bool IsUp { get; private set; }
/// <summary> /// <summary>
/// Creates a new CompletionWindowBase. /// Creates a new CompletionWindowBase.
/// </summary> /// </summary>
@ -307,6 +312,9 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
} }
if (bounds.Bottom > workingScreen.Bottom) { if (bounds.Bottom > workingScreen.Bottom) {
bounds.Y = locationTop.Y - bounds.Height; bounds.Y = locationTop.Y - bounds.Height;
IsUp = true;
} else {
IsUp = false;
} }
if (bounds.Y < workingScreen.Top) { if (bounds.Y < workingScreen.Top) {
bounds.Y = workingScreen.Top; bounds.Y = workingScreen.Top;
@ -318,6 +326,15 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
this.Top = bounds.Y; this.Top = bounds.Y;
} }
/// <inheritdoc/>
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
if (sizeInfo.HeightChanged && IsUp) {
this.Top += sizeInfo.PreviousSize.Height - sizeInfo.NewSize.Height;
}
}
/// <summary> /// <summary>
/// Gets/sets whether the completion window should expect text insertion at the start offset, /// Gets/sets whether the completion window should expect text insertion at the start offset,
/// which not go into the completion region, but before it. /// which not go into the completion region, but before it.

Loading…
Cancel
Save