Index: vte3-0.34.6-public/src/vte.c
===================================================================
--- vte3-0.34.6-public.orig/src/vte.c	2013-09-23 10:32:59.935346000 +0400
+++ vte3-0.34.6-public/src/vte.c	2013-09-23 10:47:17.287346000 +0400
@@ -8042,13 +8042,43 @@
 	}
 	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);
+		/* row_delta > 0 terminal height was decreased
+		 * row_delta < 0 terminal height was increased
+		 * */
+		glong row_delta = old_visible_rows - terminal->row_count;
+		
+		/* Subtract the scrolling offset from the row start so that the
+		 * resulting rectangle is relative to the visible portion of the
+		 * buffer. */
+		glong cursor_row = screen->cursor_current.row-screen->insert_delta;
+
+		if (row_delta > 0 && 
+			ring_length > terminal->row_count && 
+			cursor_row>=terminal->row_count) {
+			/*limit scroll delta and insert delta*/
+			if(screen->scroll_delta+row_delta>screen->cursor_current.row)
+				row_delta=screen->cursor_current.row-screen->scroll_delta;
+			if(screen->insert_delta+row_delta>screen->cursor_current.row)
+				row_delta=screen->cursor_current.row-screen->insert_delta;	
+			/*firstly remove the unused space below the cursor*/
+			if(cursor_row>old_visible_rows)
+				row_delta -= (cursor_row - old_visible_rows);
+				
+			screen->insert_delta += row_delta;
+			
 			vte_terminal_queue_adjustment_value_changed (
 					terminal,
-					screen->scroll_delta + delta);
+					screen->scroll_delta + row_delta);
+		}else
+		if (row_delta < 0 &&
+			ring_length > terminal->row_count) {
+			glong row_delta = old_visible_rows - terminal->row_count;
+			/*limit insert delta*/
+			if(screen->insert_delta+row_delta < 0)
+				row_delta = -screen->insert_delta;
+			screen->insert_delta += row_delta;
 		}
 		gtk_widget_queue_resize_no_redraw (&terminal->widget);
 		/* Our visible text changed. */
Index: vte3-0.34.6-public/src/vteseq.c
===================================================================
--- vte3-0.34.6-public.orig/src/vteseq.c	2013-09-23 10:32:59.935346000 +0400
+++ vte3-0.34.6-public/src/vteseq.c	2013-09-23 10:32:59.931346000 +0400
@@ -1089,7 +1089,7 @@
 			rowdata = _vte_ring_index_writable (screen->row_data, i);
 			g_assert(rowdata != NULL);
 		} else {
-			rowdata = _vte_terminal_ring_append (terminal, FALSE);
+			continue;//just skip non existent row
 		}
 		/* Pad out the row. */
 		_vte_row_data_fill (rowdata, &screen->fill_defaults, terminal->column_count);
