mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
another attempt for IDEA-89059 Selected item is scrolled off the bottom of the code completion popup
This commit is contained in:
@@ -477,16 +477,13 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
updateListHeight(listModel);
|
||||
|
||||
myList.setSelectedIndex(toSelect);
|
||||
if (onExplicitAction && myShown) {
|
||||
myList.ensureIndexIsVisible(toSelect);
|
||||
}
|
||||
return !oldModel.equals(items);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isSelectionVisible() {
|
||||
return myList.getFirstVisibleIndex() <= myList.getSelectedIndex() && myList.getSelectedIndex() <= myList.getLastVisibleIndex();
|
||||
return ListScrollingUtil.isIndexFullyVisible(myList, myList.getSelectedIndex());
|
||||
}
|
||||
|
||||
private boolean checkReused() {
|
||||
@@ -1286,7 +1283,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
}
|
||||
HintManagerImpl.updateLocation(this, myEditor, rectangle.getLocation());
|
||||
|
||||
if (reused || selectionVisible) {
|
||||
if (reused || selectionVisible || onExplicitAction) {
|
||||
ensureSelectionVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +176,20 @@ public class ListScrollingUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isIndexFullyVisible(JList list, int index) {
|
||||
int first = list.getFirstVisibleIndex();
|
||||
int last = list.getLastVisibleIndex();
|
||||
|
||||
if (index < 0 || first < 0 || last < 0 || index < first || index > last) {
|
||||
return false;
|
||||
}
|
||||
if (index > first && index < last) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return list.getVisibleRect().contains(list.getCellBounds(index, index));
|
||||
}
|
||||
|
||||
private static int getVisibleRowCount(JList list) {
|
||||
return list.getLastVisibleIndex() - list.getFirstVisibleIndex() + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user