mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed PY-16984 iPython notebook clicking in cell causes odd scrolling
handled up/down inside code cell
This commit is contained in:
@@ -452,4 +452,8 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor {
|
||||
public VirtualFile getVirtualFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
public JScrollPane getScrollPane() {
|
||||
return myScrollPane;
|
||||
}
|
||||
}
|
||||
|
||||
+22
@@ -26,6 +26,7 @@ import com.intellij.ui.components.panels.HorizontalLayout;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.ipnb.editor.IpnbEditorUtil;
|
||||
import org.jetbrains.plugins.ipnb.editor.IpnbFileEditor;
|
||||
import org.jetbrains.plugins.ipnb.editor.actions.IpnbRunCellAction;
|
||||
import org.jetbrains.plugins.ipnb.editor.actions.IpnbRunCellBaseAction;
|
||||
import org.jetbrains.plugins.ipnb.editor.actions.IpnbRunCellInplaceAction;
|
||||
@@ -97,6 +98,24 @@ public class IpnbCodeSourcePanel extends IpnbPanel<JComponent, IpnbCodeCell> imp
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVisibleArea(boolean up) {
|
||||
final IpnbFileEditor fileEditor = myParent.getFileEditor();
|
||||
final IpnbFilePanel ipnbPanel = fileEditor.getIpnbFilePanel();
|
||||
final Rectangle rect = ipnbPanel.getVisibleRect();
|
||||
|
||||
final Rectangle cellBounds = IpnbCodeSourcePanel.this.getIpnbCodePanel().getBounds();
|
||||
final JScrollPane scrollPane = fileEditor.getScrollPane();
|
||||
|
||||
final double y = cellBounds.getY() + myEditor.visualPositionToXY(myEditor.getCaretModel().getVisualPosition()).getY();
|
||||
int delta = myEditor.getLineHeight();
|
||||
if (y <= rect.getY() && up) {
|
||||
scrollPane.getVerticalScrollBar().setValue(rect.y - delta);
|
||||
}
|
||||
if (y + delta > rect.getY() + rect.getHeight() && !up) {
|
||||
scrollPane.getVerticalScrollBar().setValue(rect.y + delta);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
final int keyCode = e.getKeyCode();
|
||||
@@ -120,6 +139,9 @@ public class IpnbCodeSourcePanel extends IpnbPanel<JComponent, IpnbCodeCell> imp
|
||||
else if (keyCode == KeyEvent.VK_ENTER && InputEvent.SHIFT_DOWN_MASK == e.getModifiersEx()) {
|
||||
IpnbRunCellBaseAction.runCell(ipnbFilePanel, true);
|
||||
}
|
||||
else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) {
|
||||
updateVisibleArea(keyCode == KeyEvent.VK_UP);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user