- 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: remember current problem set's filename
- 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
- 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
- fix: when oj problem grabbed by competitive companion received,

View File

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