--- C:\temp\wxWidgets-2.6.2\contrib\src\stc\scintilla\include\Scintilla.h	2005-09-09 16:29:04.000 +0200
+++ C:\dev\sdk\wxWidgets-2.6.2\contrib\src\stc\scintilla\include\Scintilla.h	2005-11-11 16:36:24.000 +0100
@@ -612,7 +612,8 @@
 #define SC_MOD_CHANGEMARKER 0x200
 #define SC_MOD_BEFOREINSERT 0x400
 #define SC_MOD_BEFOREDELETE 0x800
-#define SC_MODEVENTMASKALL 0xF77
+#define SC_START_ACTION 0x2000
+#define SC_MODEVENTMASKALL 0x2F77
 #define SCEN_CHANGE 768
 #define SCEN_SETFOCUS 512
 #define SCEN_KILLFOCUS 256

--- C:\temp\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\CellBuffer.cxx	2005-02-12 13:35:22.000 +0100
+++ C:\dev\sdk\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\CellBuffer.cxx	2005-11-11 16:36:24.000 +0100
@@ -445,7 +445,7 @@
 	}
 }
 
-void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) {
+void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData, bool &implicitBegin) {
 	EnsureUndoRoom();
 	//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
 	//Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
@@ -453,6 +453,8 @@
 	if (currentAction < savePoint) {
 		savePoint = -1;
 	}
+	
+	int oldCurrentAction = currentAction;
 	if (currentAction >= 1) {
 		if (0 == undoSequenceDepth) {
 			// Top level actions may not always be coalesced
@@ -496,13 +498,14 @@
 	} else {
 		currentAction++;
 	}
+	implicitBegin = undoSequenceDepth==0 && oldCurrentAction!=currentAction;
 	actions[currentAction].Create(at, position, data, lengthData);
 	currentAction++;
 	actions[currentAction].Create(startAction);
 	maxAction = currentAction;
 }
 
-void UndoHistory::BeginUndoAction() {
+bool UndoHistory::BeginUndoAction() {
 	EnsureUndoRoom();
 	if (undoSequenceDepth == 0) {
 		if (actions[currentAction].at != startAction) {
@@ -513,10 +516,12 @@
 		actions[currentAction].mayCoalesce = false;
 	}
 	undoSequenceDepth++;
+	return undoSequenceDepth==1;
 }
 
 void UndoHistory::EndUndoAction() {
 	EnsureUndoRoom();
+
 	undoSequenceDepth--;
 	if (0 == undoSequenceDepth) {
 		if (actions[currentAction].at != startAction) {
@@ -713,7 +718,7 @@
 	return ByteAt(position*2 + 1);
 }
 
-const char *CellBuffer::InsertString(int position, char *s, int insertLength) {
+const char *CellBuffer::InsertString(int position, char *s, int insertLength, bool &implicitBegin) {
 	char *data = 0;
 	// InsertString and DeleteChars are the bottleneck though which all changes occur
 	if (!readOnly) {
@@ -724,7 +729,7 @@
 			for (int i = 0; i < insertLength / 2; i++) {
 				data[i] = s[i * 2];
 			}
-			uh.AppendAction(insertAction, position, data, insertLength / 2);
+			uh.AppendAction(insertAction, position, data, insertLength / 2, implicitBegin);
 		}
 
 		BasicInsertString(position, s, insertLength);
@@ -732,11 +737,11 @@
 	return data;
 }
 
-void CellBuffer::InsertCharStyle(int position, char ch, char style) {
+void CellBuffer::InsertCharStyle(int position, char ch, char style, bool &implicitBegin) {
 	char s[2];
 	s[0] = ch;
 	s[1] = style;
-	InsertString(position*2, s, 2);
+	InsertString(position*2, s, 2, implicitBegin);
 }
 
 bool CellBuffer::SetStyleAt(int position, char style, char mask) {
@@ -766,7 +771,7 @@
 	return changed;
 }
 
-const char *CellBuffer::DeleteChars(int position, int deleteLength) {
+const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &implicitBegin) {
 	// InsertString and DeleteChars are the bottleneck though which all changes occur
 	char *data = 0;
 	if (!readOnly) {
@@ -776,7 +781,7 @@
 			for (int i = 0; i < deleteLength / 2; i++) {
 				data[i] = ByteAt(position + i * 2);
 			}
-			uh.AppendAction(removeAction, position, data, deleteLength / 2);
+			uh.AppendAction(removeAction, position, data, deleteLength / 2, implicitBegin);
 		}
 
 		BasicDeleteChars(position, deleteLength);
@@ -1015,8 +1020,8 @@
 	return collectingUndo;
 }
 
-void CellBuffer::BeginUndoAction() {
-	uh.BeginUndoAction();
+bool CellBuffer::BeginUndoAction() {
+	return uh.BeginUndoAction();
 }
 
 void CellBuffer::EndUndoAction() {

--- C:\temp\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\CellBuffer.h	2005-02-12 13:35:22.000 +0100
+++ C:\dev\sdk\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\CellBuffer.h	2005-11-11 16:36:24.000 +0100
@@ -119,9 +119,10 @@
 	UndoHistory();
 	~UndoHistory();
 
-	void AppendAction(actionType at, int position, char *data, int length);
+	void AppendAction(actionType at, int position, char *data, int length, bool &implicitBegin);
 
-	void BeginUndoAction();
+	// returns true if an actual transaction was opened
+	bool BeginUndoAction();
 	void EndUndoAction();
 	void DropUndoSequence();
 	void DeleteUndoHistory();
@@ -190,15 +191,15 @@
 	int Lines();
 	int LineStart(int line);
 	int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
-	const char *InsertString(int position, char *s, int insertLength);
-	void InsertCharStyle(int position, char ch, char style);
+	const char *InsertString(int position, char *s, int insertLength, bool &implicitBegin);
+	void InsertCharStyle(int position, char ch, char style, bool &implicitBegin);
 
 	/// Setting styles for positions outside the range of the buffer is safe and has no effect.
 	/// @return true if the style of a character is changed.
 	bool SetStyleAt(int position, char style, char mask='\377');
 	bool SetStyleFor(int position, int length, char style, char mask);
 
-	const char *DeleteChars(int position, int deleteLength);
+	const char *DeleteChars(int position, int deleteLength, bool &implicitBegin);
 
 	bool IsReadOnly();
 	void SetReadOnly(bool set);
@@ -222,7 +223,7 @@
 
 	bool SetUndoCollection(bool collectUndo);
 	bool IsCollectingUndo();
-	void BeginUndoAction();
+	bool BeginUndoAction();
 	void EndUndoAction();
 	void DeleteUndoHistory();
 
--- C:\temp\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\Document.cxx	2005-02-12 13:35:22.000 +0100
+++ C:\dev\sdk\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\Document.cxx	2005-11-11 16:36:24.000 +0100
@@ -96,6 +96,17 @@
 	return curRefCount;
 }
 
+bool Document::BeginUndoAction()
+{
+	if (cb.BeginUndoAction())
+	{
+		NotifyModified(DocModification(SC_START_ACTION));
+		return true;
+	}
+	return false;
+}
+
+
 void Document::SetSavePoint() {
 	cb.SetSavePoint();
 	NotifySavePoint(true);
@@ -362,7 +373,10 @@
 			        0, 0));
 			int prevLinesTotal = LinesTotal();
 			bool startSavePoint = cb.IsSavePoint();
-			const char *text = cb.DeleteChars(pos * 2, len * 2);
+			bool implicitBegin=false;
+			const char *text = cb.DeleteChars(pos * 2, len * 2, implicitBegin);
+			if (implicitBegin)
+				NotifyModified(DocModification(SC_START_ACTION));
 			if (startSavePoint && cb.IsCollectingUndo())
 				NotifySavePoint(!startSavePoint);
 			if ((pos < Length()) || (pos == 0))
@@ -401,7 +415,10 @@
 			        0, s));
 			int prevLinesTotal = LinesTotal();
 			bool startSavePoint = cb.IsSavePoint();
-			const char *text = cb.InsertString(position, s, insertLength);
+			bool implicitBegin=false;
+			const char *text = cb.InsertString(position, s, insertLength, implicitBegin);
+			if (implicitBegin)
+				NotifyModified(DocModification(SC_START_ACTION));
 			if (startSavePoint && cb.IsCollectingUndo())
 				NotifySavePoint(!startSavePoint);
 			ModifiedAt(position / 2);

--- C:\temp\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\Document.h	2005-02-12 13:35:22.000 +0100
+++ C:\dev\sdk\wxWidgets-2.6.2\contrib\src\stc\scintilla\src\Document.h	2005-11-11 16:36:24.000 +0100
@@ -145,7 +145,7 @@
 		return cb.SetUndoCollection(collectUndo);
 	}
 	bool IsCollectingUndo() { return cb.IsCollectingUndo(); }
-	void BeginUndoAction() { cb.BeginUndoAction(); }
+	bool BeginUndoAction();
 	void EndUndoAction() { cb.EndUndoAction(); }
 	void SetSavePoint();
 	bool IsSavePoint() { return cb.IsSavePoint(); }

