- fix: undo one symbol completion as a whole operation
This commit is contained in:
parent
1b8f3de21f
commit
b436312d19
1
NEWS.md
1
NEWS.md
|
@ -18,6 +18,7 @@ Red Panda C++ Version 0.14.5
|
|||
- fix: the scroll speed of mouse selection/drag is too fast.
|
||||
- fix: the scroll behavior of mouse dragging on the editor's edge is not correct
|
||||
- fix: calculation of caret position is not in consistence.
|
||||
- fix: undo one symbol completion as a whole operation
|
||||
|
||||
Red Panda C++ Version 0.14.4
|
||||
- enhancement: git - log
|
||||
|
|
|
@ -2053,10 +2053,12 @@ bool Editor::handleParentheseCompletion()
|
|||
QuoteStatus status = getQuoteStatus();
|
||||
if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(SynEditorCommand::ecChar,'(');
|
||||
BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(SynEditorCommand::ecChar,')');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
}
|
||||
|
@ -2102,10 +2104,12 @@ bool Editor::handleBracketCompletion()
|
|||
// QuoteStatus status = getQuoteStatus();
|
||||
// if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(SynEditorCommand::ecChar,'[');
|
||||
BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(SynEditorCommand::ecChar,']');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
// }
|
||||
|
@ -2136,11 +2140,13 @@ bool Editor::handleMultilineCommentCompletion()
|
|||
{
|
||||
if ((caretX()-2 < lineText().length()) && (lineText()[caretX() - 2] == '/')) {
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(SynEditorCommand::ecChar,'*');
|
||||
BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(SynEditorCommand::ecChar,'*');
|
||||
commandProcessor(SynEditorCommand::ecChar,'/');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
}
|
||||
|
@ -2156,6 +2162,7 @@ bool Editor::handleBraceCompletion()
|
|||
i--;
|
||||
}
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(SynEditorCommand::ecChar,'{');
|
||||
BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(SynEditorCommand::ecChar,'}');
|
||||
|
@ -2172,6 +2179,7 @@ bool Editor::handleBraceCompletion()
|
|||
commandProcessor(SynEditorCommand::ecChar,';');
|
||||
}
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
}
|
||||
|
@ -2218,10 +2226,12 @@ bool Editor::handleSingleQuoteCompletion()
|
|||
if (ch == 0 || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
||||
// insert ''
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(SynEditorCommand::ecChar,'\'');
|
||||
BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(SynEditorCommand::ecChar,'\'');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
}
|
||||
|
@ -2244,10 +2254,12 @@ bool Editor::handleDoubleQuoteCompletion()
|
|||
if ((ch == 0) || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
||||
// insert ""
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(SynEditorCommand::ecChar,'"');
|
||||
BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(SynEditorCommand::ecChar,'"');
|
||||
setCaretXY(oldCaret);
|
||||
endUndoBlock();
|
||||
endUpdate();
|
||||
return true;
|
||||
}
|
||||
|
@ -2264,11 +2276,13 @@ bool Editor::handleGlobalIncludeCompletion()
|
|||
if (!s.startsWith("include")) //it's not #include
|
||||
return false;
|
||||
beginUpdate();
|
||||
beginUndoBlock();
|
||||
commandProcessor(SynEditorCommand::ecChar,'<');
|
||||
BufferCoord oldCaret = caretXY();
|
||||
commandProcessor(SynEditorCommand::ecChar,'>');
|
||||
setCaretXY(oldCaret);
|
||||
endUpdate();
|
||||
endUndoBlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -441,6 +441,16 @@ bool SynEdit::getHighlighterAttriAtRowColEx(const BufferCoord &XY, QString &Toke
|
|||
return false;
|
||||
}
|
||||
|
||||
void SynEdit::beginUndoBlock()
|
||||
{
|
||||
mUndoList->BeginBlock();
|
||||
}
|
||||
|
||||
void SynEdit::endUndoBlock()
|
||||
{
|
||||
mUndoList->EndBlock();
|
||||
}
|
||||
|
||||
void SynEdit::beginUpdate()
|
||||
{
|
||||
incPaintLock();
|
||||
|
|
|
@ -259,6 +259,9 @@ public:
|
|||
SynHighlighterTokenType& TokenType, SynTokenKind &TokenKind, int &Start,
|
||||
PSynHighlighterAttribute& Attri);
|
||||
|
||||
void beginUndoBlock();
|
||||
void endUndoBlock();
|
||||
|
||||
//Commands
|
||||
virtual void cutToClipboard() { commandProcessor(SynEditorCommand::ecCut);}
|
||||
virtual void copyToClipboard() { commandProcessor(SynEditorCommand::ecCopy);}
|
||||
|
|
Loading…
Reference in New Issue