LogicalPosition (@NotNull Point p) { return ReadAction.compute(() -> { Point pp = p.x >= 0 && p.y >= 0 ? p : new Point(Math.max(p.x, 0), Math.max(p.y, 0)); return visualToLogicalPosition(xyToVisualPosition(pp)); }); }