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