=== modified file 'gucharmap/gucharmap-chartable.c'
--- gucharmap/gucharmap-chartable.c	2008-03-23 13:36:47 +0000
+++ gucharmap/gucharmap-chartable.c	2008-03-23 13:48:09 +0000
@@ -1568,6 +1568,8 @@
     }
 }
 
+#define FIRST_CELL_IN_SAME_ROW(x) ((x) - ((x) % chartable->cols))
+
 static void
 gucharmap_chartable_size_allocate (GtkWidget *widget,
                                    GtkAllocation *allocation)
@@ -1576,6 +1578,7 @@
   GucharmapChartablePrivate *priv = chartable->priv;
   int old_rows, old_cols;
   int total_extra_pixels;
+  int new_first_cell;
 
   GTK_WIDGET_CLASS (gucharmap_chartable_parent_class)->size_allocate (widget, allocation);
 
@@ -1613,7 +1616,17 @@
   if (priv->rows == old_rows && priv->cols == old_cols)
     return;
 
-  priv->page_first_cell = priv->active_cell - (priv->active_cell % priv->cols);
+  new_first_cell = FIRST_CELL_IN_SAME_ROW (priv->active_cell);
+  if ((new_first_cell + priv->rows*priv->cols) > (priv->last_cell))
+    {
+      /* last cell is visible, so make sure it is in the last row */
+      new_first_cell = FIRST_CELL_IN_SAME_ROW (priv->last_cell) - ((priv->rows - 1)*priv->cols);
+      if (new_first_cell < 0)
+        {
+          new_first_cell = 0;
+        }
+    }
+  priv->page_first_cell = new_first_cell;
 
   update_scrollbar_adjustment (chartable);
 }

