=== modified file 'gucharmap/gucharmap-chartable.c'
--- gucharmap/gucharmap-chartable.c	2008-02-02 09:21:40 +0000
+++ gucharmap/gucharmap-chartable.c	2008-03-06 08:37:09 +0000
@@ -1343,6 +1343,8 @@
     }
 }
 
+#define FIRST_CELL_IN_SAME_ROW(x) ((x) - ((x) % chartable->cols))
+
 static void
 gucharmap_chartable_size_allocate (GtkWidget *widget,
                                    GtkAllocation *allocation)
@@ -1350,6 +1352,7 @@
   GucharmapChartable *chartable = GUCHARMAP_CHARTABLE (widget);
   int old_rows, old_cols;
   int total_extra_pixels;
+  int new_first_cell;
 
   GTK_WIDGET_CLASS (gucharmap_chartable_parent_class)->size_allocate (widget, allocation);
 
@@ -1386,8 +1389,15 @@
 
   if (chartable->rows == old_rows && chartable->cols == old_cols)
     return;
-
-  chartable->page_first_cell = chartable->active_cell - (chartable->active_cell % chartable->cols);
+  
+  new_first_cell = FIRST_CELL_IN_SAME_ROW (chartable->active_cell);
+  if ((new_first_cell + chartable->rows*chartable->cols) > (chartable->last_cell))
+  {
+    /* last cell is visible, so make sure it is in the last row */
+    new_first_cell = FIRST_CELL_IN_SAME_ROW (chartable->last_cell) - ((chartable->rows - 1)*chartable->cols);
+    if (new_first_cell < 0) new_first_cell = 0;
+  }
+  chartable->page_first_cell = new_first_cell;
 
   update_scrollbar_adjustment (chartable);
 }

