Index: gtksourceundomanager.c
===================================================================
RCS file: /cvs/gnome/gtksourceview/gtksourceview/gtksourceundomanager.c,v
retrieving revision 1.4
diff -u -r1.4 gtksourceundomanager.c
--- gtksourceundomanager.c	27 Sep 2003 22:54:08 -0000	1.4
+++ gtksourceundomanager.c	10 Jan 2005 03:45:48 -0000
@@ -614,14 +614,12 @@
 	if (um->priv->running_not_undoable_actions > 0)
 		return;
 
-	g_return_if_fail (strlen (text) == (guint)length);
-	
 	undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT;
 
 	undo_action.action.insert.pos    = gtk_text_iter_get_offset (pos);
 	undo_action.action.insert.text   = (gchar*) text;
-	undo_action.action.insert.length = length;
 	undo_action.action.insert.chars  = g_utf8_strlen (text, length);
+	undo_action.action.insert.length = g_utf8_offset_to_pointer (text, undo_action.action.insert.chars) - text;
 
 	if ((undo_action.action.insert.chars > 1) || (g_utf8_get_char (text) == '\n'))
 
@@ -717,7 +715,7 @@
 		*action = undo_action;
 
 		if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT)
-			action->action.insert.text = g_strdup (undo_action.action.insert.text);
+			action->action.insert.text = g_strndup (undo_action.action.insert.text, undo_action.action.insert.length);
 		else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE)
 			action->action.delete.text = g_strdup (undo_action.action.delete.text); 
 		else
@@ -946,7 +944,8 @@
 			return FALSE;
 		}
 
-		str = g_strdup_printf ("%s%s", last_action->action.insert.text, 
+		str = g_strdup_printf ("%s%*s", last_action->action.insert.text, 
+				undo_action->action.insert.length,
 				undo_action->action.insert.text);
 		
 		g_free (last_action->action.insert.text);
