Index: vte3-0.34.6/src/vte.c
===================================================================
--- vte3-0.34.6.orig/src/vte.c	2013-09-19 11:31:35.311346000 +0400
+++ vte3-0.34.6/src/vte.c	2013-09-19 14:42:07.923346000 +0400
@@ -8042,13 +8042,34 @@
 	}
 	if (old_rows != terminal->row_count || old_columns != terminal->column_count) {
 		VteScreen *screen = terminal->pvt->screen;
-		glong visible_rows = MIN (old_rows, _vte_ring_length (screen->row_data));
-		if (terminal->row_count < visible_rows) {
-			glong delta = visible_rows - terminal->row_count;
-			screen->insert_delta += delta;
+		glong old_visible_rows = MIN (old_rows, _vte_ring_length (screen->row_data));
+		glong ring_length=_vte_ring_length (screen->row_data);
+		/*difference between visible window and virtual window
+		* if visible_rows was decrised then delta will be negative!*/
+		glong delta = old_visible_rows - terminal->row_count;
+		glong last_index_in_ring=ring_length-1;/*bottom line in the ring*/
+		if (terminal->row_count < old_visible_rows && 
+			screen->cursor_current.row+delta > last_index_in_ring) {
+			/*if visible row count was decrised (terminal->row_count < old_visible)
+			 * and cursor position + (-delta) >  last_index_in_ring (new actual visible window is less than virtual window)
+			 * move virtual cursor up to new insert position
+			 * scroll content up by -delta*/
+			screen->insert_delta += (screen->cursor_current.row+delta-last_index_in_ring);
 			vte_terminal_queue_adjustment_value_changed (
 					terminal,
 					screen->scroll_delta + delta);
+		}else
+		if (terminal->row_count > old_visible_rows &&
+			screen->cursor_current.row+delta < last_index_in_ring) {
+			/*if visible row count was increased (terminal->row_count > old_visible_rows)
+			 * and cursor position + (delta) <  last_index_in_ring (virtual window size more than new actual visible window)
+			 * move virtual cursor down to new insert position
+			 * scroll content down by delta*/
+			screen->insert_delta += (screen->cursor_current.row+delta-last_index_in_ring);
+			/* is not necessary but will work
+			 * vte_terminal_queue_adjustment_value_changed (
+					terminal,
+					screen->scroll_delta + delta);*/
 		}
 		gtk_widget_queue_resize_no_redraw (&terminal->widget);
 		/* Our visible text changed. */
