- fix: parenthesis skip doesn't work when editing non-c/c++ files

This commit is contained in:
Roy Qu 2022-04-13 20:04:10 +08:00
parent 94a99e983e
commit 9254a13d84
2 changed files with 46 additions and 44 deletions

View File

@ -3,9 +3,10 @@ Red Panda C++ Version 1.0.4
- enhancement: add help link for regular expression in search dialog - enhancement: add help link for regular expression in search dialog
- enhancement: remember current problem set's filename - enhancement: remember current problem set's filename
- enhancement: F1 shorcut opens offcial website - enhancement: F1 shorcut opens offcial website
- enhancement: don't auto complete '(', if the next non-space char is neither '(' nor ident char - enhancement: don't auto complete '(', if the next non-space char is '(' or ident char
- enhancement: if a project's unit encoding is the same with project's encoding, don't save its encoding - enhancement: if a project's unit encoding is the same with project's encoding, don't save its encoding
- fix: files will be saved to default encoding inspite of its original encoding - fix: files will be saved to default encoding inspite of its original encoding
- fix: parenthesis skip doesn't work when editing non-c/c++ files
Red Panda C++ Version 1.0.3 Red Panda C++ Version 1.0.3
- fix: when oj problem grabbed by competitive companion received, - fix: when oj problem grabbed by competitive companion received,

View File

@ -2165,24 +2165,22 @@ bool Editor::handleParentheseSkip()
if (status != QuoteStatus::NotQuote) if (status != QuoteStatus::NotQuote)
return false; return false;
if (!highlighter())
return false;
if (lines()->count()==0) if (lines()->count()==0)
return false; return false;
SynRangeState lastLineState = lines()->ranges(lines()->count()-1); if (highlighter()) {
if (lastLineState.parenthesisLevel==0) { SynRangeState lastLineState = lines()->ranges(lines()->count()-1);
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over if (lastLineState.parenthesisLevel==0) {
return true; setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
return true;
}
} else {
BufferCoord pos = getMatchingBracket();
if (pos.Line != 0) {
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
return true;
}
} }
return false; return false;
// BufferCoord pos = getMatchingBracket();
// if (pos.Line != 0) {
// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
// return true;
// }
// if FunctionTipAllowed then
// fFunctionTip.Activated := false;
// return false;
} }
bool Editor::handleBracketCompletion() bool Editor::handleBracketCompletion()
@ -2217,20 +2215,22 @@ bool Editor::handleBracketSkip()
{ {
if (getCurrentChar() != ']') if (getCurrentChar() != ']')
return false; return false;
if (!highlighter())
return false;
if (lines()->count()==0) if (lines()->count()==0)
return false; return false;
SynRangeState lastLineState = lines()->ranges(lines()->count()-1); if (highlighter()) {
if (lastLineState.bracketLevel==0) { SynRangeState lastLineState = lines()->ranges(lines()->count()-1);
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over if (lastLineState.bracketLevel==0) {
return true; setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
return true;
}
} else {
BufferCoord pos = getMatchingBracket();
if (pos.Line != 0) {
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
return true;
}
} }
// BufferCoord pos = getMatchingBracket();
// if (pos.Line != 0) {
// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
// return true;
// }
return false; return false;
} }
@ -2301,27 +2301,28 @@ bool Editor::handleBraceSkip()
{ {
if (getCurrentChar() != '}') if (getCurrentChar() != '}')
return false; return false;
if (!highlighter())
return false;
if (lines()->count()==0) if (lines()->count()==0)
return false; return false;
SynRangeState lastLineState = lines()->ranges(lines()->count()-1); if (highlighter()) {
if (lastLineState.braceLevel==0) { SynRangeState lastLineState = lines()->ranges(lines()->count()-1);
bool oldInsertMode = insertMode(); if (lastLineState.braceLevel==0) {
setInsertMode(false); //set mode to overwrite bool oldInsertMode = insertMode();
commandProcessor(SynEditorCommand::ecChar,'}'); setInsertMode(false); //set mode to overwrite
setInsertMode(oldInsertMode); commandProcessor(SynEditorCommand::ecChar,'}');
return true; setInsertMode(oldInsertMode);
return true;
}
} else {
BufferCoord pos = getMatchingBracket();
if (pos.Line != 0) {
bool oldInsertMode = insertMode();
setInsertMode(false); //set mode to overwrite
commandProcessor(SynEditorCommand::ecChar,'}');
setInsertMode(oldInsertMode);
return true;
}
} }
// BufferCoord pos = getMatchingBracket();
// if (pos.Line != 0) {
// bool oldInsertMode = insertMode();
// setInsertMode(false); //set mode to overwrite
// commandProcessor(SynEditorCommand::ecChar,'}');
// setInsertMode(oldInsertMode);
//// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
// return true;
// }
return false; return false;
} }