Skip to content
Open
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
14 changes: 12 additions & 2 deletions src/AvaloniaEdit/CodeCompletion/CompletionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ private void OnPointerPressed(object sender, PointerPressedEventArgs e)
if (!e.GetCurrentPoint(visual).Properties.IsLeftButtonPressed)
return;

// Ignore event if pointer is outside the selected item (e.g. when the scrollbar is clicked).
if (!IsPointerOverSelectedItem(e))
return;

RequestInsertion(e);
}

Expand All @@ -258,13 +262,19 @@ private void OnPointerReleased(object sender, PointerReleasedEventArgs e)
return;

// Ignore event if pointer is released outside the selected item.
var listBoxItem = _listBox.ContainerFromIndex(_listBox.SelectedIndex);
if (listBoxItem == null || !this.GetVisualsAt(e.GetPosition(this)).Any(v => v == listBoxItem || listBoxItem.IsVisualAncestorOf(v)))
if (!IsPointerOverSelectedItem(e))
return;

RequestInsertion(e);
}

private bool IsPointerOverSelectedItem(PointerEventArgs e)
{
var listBoxItem = _listBox.ContainerFromIndex(_listBox.SelectedIndex);
return listBoxItem != null && this.GetVisualsAt(e.GetPosition(this))
.Any(v => v == listBoxItem || listBoxItem.IsVisualAncestorOf(v));
}

private void OnDoubleTapped(object sender, TappedEventArgs e)
{
RequestInsertion(e);
Expand Down