diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CellBuffer.cxx | 17 | ||||
-rw-r--r-- | src/CellBuffer.h | 6 | ||||
-rw-r--r-- | src/Document.cxx | 10 |
3 files changed, 19 insertions, 14 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 1109a17fb..a6c0cf577 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -316,10 +316,10 @@ void LineVector::DeleteMark(int line, int markerNum, bool all) { delete linesData[line].handleSet; linesData[line].handleSet = 0; } else { - bool performedDeletion = + bool performedDeletion = linesData[line].handleSet->RemoveNumber(markerNum); while (all && performedDeletion) { - performedDeletion = + performedDeletion = linesData[line].handleSet->RemoveNumber(markerNum); } if (linesData[line].handleSet->Length() == 0) { @@ -446,7 +446,8 @@ void UndoHistory::EnsureUndoRoom() { } } -void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) { +void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData, + bool &startSequence) { EnsureUndoRoom(); //Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction); //Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at, @@ -454,6 +455,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng if (currentAction < savePoint) { savePoint = -1; } + int oldCurrentAction = currentAction; if (currentAction >= 1) { if (0 == undoSequenceDepth) { // Top level actions may not always be coalesced @@ -497,6 +499,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng } else { currentAction++; } + startSequence = oldCurrentAction != currentAction; actions[currentAction].Create(at, position, data, lengthData); currentAction++; actions[currentAction].Create(startAction); @@ -714,7 +717,7 @@ char CellBuffer::StyleAt(int position) { 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 &startSequence) { char *data = 0; // InsertString and DeleteChars are the bottleneck though which all changes occur if (!readOnly) { @@ -725,7 +728,7 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) { for (int i = 0; i < insertLength / 2; i++) { data[i] = s[i * 2]; } - uh.AppendAction(insertAction, position / 2, data, insertLength / 2); + uh.AppendAction(insertAction, position / 2, data, insertLength / 2, startSequence); } BasicInsertString(position, s, insertLength); @@ -760,7 +763,7 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mas return changed; } -const char *CellBuffer::DeleteChars(int position, int deleteLength) { +const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) { // InsertString and DeleteChars are the bottleneck though which all changes occur PLATFORM_ASSERT(deleteLength > 0); char *data = 0; @@ -771,7 +774,7 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength) { for (int i = 0; i < deleteLength / 2; i++) { data[i] = ByteAt(position + i * 2); } - uh.AppendAction(removeAction, position / 2, data, deleteLength / 2); + uh.AppendAction(removeAction, position / 2, data, deleteLength / 2, startSequence); } BasicDeleteChars(position, deleteLength); diff --git a/src/CellBuffer.h b/src/CellBuffer.h index bb81fd572..92bbfa0da 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -119,7 +119,7 @@ public: UndoHistory(); ~UndoHistory(); - void AppendAction(actionType at, int position, char *data, int length); + void AppendAction(actionType at, int position, char *data, int length, bool &startSequence); void BeginUndoAction(); void EndUndoAction(); @@ -190,14 +190,14 @@ public: int Lines(); int LineStart(int line); int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } - const char *InsertString(int position, char *s, int insertLength); + const char *InsertString(int position, char *s, int insertLength, bool &startSequence); /// 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 &startSequence); bool IsReadOnly(); void SetReadOnly(bool set); diff --git a/src/Document.cxx b/src/Document.cxx index 92be92691..fee76840d 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -380,7 +380,8 @@ bool Document::DeleteChars(int pos, int len) { 0, 0)); int prevLinesTotal = LinesTotal(); bool startSavePoint = cb.IsSavePoint(); - const char *text = cb.DeleteChars(pos * 2, len * 2); + bool startSequence = false; + const char *text = cb.DeleteChars(pos * 2, len * 2, startSequence); if (startSavePoint && cb.IsCollectingUndo()) NotifySavePoint(!startSavePoint); if ((pos < Length()) || (pos == 0)) @@ -389,7 +390,7 @@ bool Document::DeleteChars(int pos, int len) { ModifiedAt(pos-1); NotifyModified( DocModification( - SC_MOD_DELETETEXT | SC_PERFORMED_USER, + SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0), pos, len, LinesTotal() - prevLinesTotal, text)); } @@ -415,13 +416,14 @@ bool Document::InsertStyledString(int position, char *s, int insertLength) { 0, s)); int prevLinesTotal = LinesTotal(); bool startSavePoint = cb.IsSavePoint(); - const char *text = cb.InsertString(position, s, insertLength); + bool startSequence = false; + const char *text = cb.InsertString(position, s, insertLength, startSequence); if (startSavePoint && cb.IsCollectingUndo()) NotifySavePoint(!startSavePoint); ModifiedAt(position / 2); NotifyModified( DocModification( - SC_MOD_INSERTTEXT | SC_PERFORMED_USER, + SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0), position / 2, insertLength / 2, LinesTotal() - prevLinesTotal, text)); } |