- enhancement: group undo will stop at spaces
This commit is contained in:
parent
ee59d80bdb
commit
74efa484be
1
NEWS.md
1
NEWS.md
|
@ -8,6 +8,7 @@ Red Panda C++ Version 0.14.5
|
|||
- enhancement: enable group undo
|
||||
- enhancement: add option "hide symbols start with underscore" and "hide synbols start with two underscore"
|
||||
- fix: can't rename project files that not openned in editor
|
||||
- enhancement: group undo will stop at spaces
|
||||
|
||||
|
||||
Red Panda C++ Version 0.14.4
|
||||
|
|
|
@ -2683,7 +2683,19 @@ void SynEdit::doAddChar(QChar AChar)
|
|||
|
||||
if (isIdentChar(AChar)) {
|
||||
doSetSelText(AChar);
|
||||
} else {
|
||||
} else if (AChar.isSpace()) {
|
||||
// break group undo chain
|
||||
mUndoList->AddChange(SynChangeReason::crNothing,
|
||||
BufferCoord{0, 0},
|
||||
BufferCoord{0, 0},
|
||||
"", SynSelectionMode::smNormal);
|
||||
doSetSelText(AChar);
|
||||
// break group undo chain
|
||||
mUndoList->AddChange(SynChangeReason::crNothing,
|
||||
BufferCoord{0, 0},
|
||||
BufferCoord{0, 0},
|
||||
"", SynSelectionMode::smNormal);
|
||||
}else {
|
||||
mUndoList->BeginBlock();
|
||||
doSetSelText(AChar);
|
||||
int oldCaretX=mCaretX-1;
|
||||
|
@ -4040,11 +4052,16 @@ void SynEdit::doUndo()
|
|||
int OldChangeNumber = Item->changeNumber();
|
||||
int SaveChangeNumber = mRedoList->blockChangeNumber();
|
||||
mRedoList->setBlockChangeNumber(Item->changeNumber());
|
||||
|
||||
{
|
||||
auto action = finally([&,this] {
|
||||
mRedoList->setBlockChangeNumber(SaveChangeNumber);
|
||||
});
|
||||
//skip group chain breakers
|
||||
if (mUndoList->LastChangeReason()==SynChangeReason::crNothing) {
|
||||
while (!mUndoList->isEmpty() && mUndoList->LastChangeReason()==SynChangeReason::crNothing) {
|
||||
doUndoItem();
|
||||
}
|
||||
}
|
||||
do {
|
||||
doUndoItem();
|
||||
Item = mUndoList->PeekItem();
|
||||
|
|
|
@ -845,6 +845,11 @@ SynChangeReason SynEditUndoList::LastChangeReason()
|
|||
return mItems.last()->changeReason();
|
||||
}
|
||||
|
||||
bool SynEditUndoList::isEmpty()
|
||||
{
|
||||
return mItems.count()==0;
|
||||
}
|
||||
|
||||
void SynEditUndoList::Lock()
|
||||
{
|
||||
mLockCount++;
|
||||
|
|
|
@ -202,6 +202,7 @@ public:
|
|||
void DeleteItem(int index);
|
||||
void EndBlock();
|
||||
SynChangeReason LastChangeReason();
|
||||
bool isEmpty();
|
||||
void Lock();
|
||||
PSynEditUndoItem PeekItem();
|
||||
PSynEditUndoItem PopItem();
|
||||
|
|
Loading…
Reference in New Issue