- enhancement: better processing of symbol completion

This commit is contained in:
Roy Qu 2022-03-02 15:45:43 +08:00
parent d93a41e496
commit 6a6f1a68e0
4 changed files with 53 additions and 8 deletions

View File

@ -10,6 +10,7 @@ Red Panda C++ Version 0.14.5
- fix: can't rename project files that not openned in editor - fix: can't rename project files that not openned in editor
- enhancement: group undo will stop at spaces - enhancement: group undo will stop at spaces
- fix: menu font size is wrong when dpi changed - fix: menu font size is wrong when dpi changed
- enhancement: better processing of symbol completion
Red Panda C++ Version 0.14.4 Red Panda C++ Version 0.14.4
- enhancement: git - log - enhancement: git - log

View File

@ -2077,14 +2077,25 @@ bool Editor::handleParentheseSkip()
} }
if (status != QuoteStatus::NotQuote) if (status != QuoteStatus::NotQuote)
return false; return false;
BufferCoord pos = getMatchingBracket();
if (pos.Line != 0) { 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 setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
return true; return true;
} }
return false;
// BufferCoord pos = getMatchingBracket();
// if (pos.Line != 0) {
// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
// return true;
// }
// if FunctionTipAllowed then // if FunctionTipAllowed then
// fFunctionTip.Activated := false; // fFunctionTip.Activated := false;
return false; // return false;
} }
bool Editor::handleBracketCompletion() bool Editor::handleBracketCompletion()
@ -2105,11 +2116,20 @@ bool Editor::handleBracketSkip()
{ {
if (getCurrentChar() != ']') if (getCurrentChar() != ']')
return false; return false;
BufferCoord pos = getMatchingBracket(); if (!highlighter())
if (pos.Line != 0) { 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 setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
return true; return true;
} }
// BufferCoord pos = getMatchingBracket();
// if (pos.Line != 0) {
// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
// return true;
// }
return false; return false;
} }
@ -2161,15 +2181,27 @@ bool Editor::handleBraceSkip()
{ {
if (getCurrentChar() != '}') if (getCurrentChar() != '}')
return false; return false;
BufferCoord pos = getMatchingBracket(); if (!highlighter())
if (pos.Line != 0) { return false;
if (lines()->count()==0)
return false;
SynRangeState lastLineState = lines()->ranges(lines()->count()-1);
if (lastLineState.braceLevel==0) {
bool oldInsertMode = insertMode(); bool oldInsertMode = insertMode();
setInsertMode(false); //set mode to overwrite setInsertMode(false); //set mode to overwrite
commandProcessor(SynEditorCommand::ecChar,'}'); commandProcessor(SynEditorCommand::ecChar,'}');
setInsertMode(oldInsertMode); setInsertMode(oldInsertMode);
// setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
return true; 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;
} }

View File

@ -374,6 +374,8 @@ void SynEditCppHighlighter::braceCloseProc()
} }
mRange.braceLevel -= 1; mRange.braceLevel -= 1;
if (mRange.braceLevel<0)
mRange.braceLevel = 0;
if (mRange.leftBraces>0) { if (mRange.leftBraces>0) {
mRange.leftBraces--; mRange.leftBraces--;
} else { } else {
@ -909,6 +911,8 @@ void SynEditCppHighlighter::roundCloseProc()
mTokenId = TokenKind::Symbol; mTokenId = TokenKind::Symbol;
mExtTokenId = ExtTokenKind::RoundClose; mExtTokenId = ExtTokenKind::RoundClose;
mRange.parenthesisLevel--; mRange.parenthesisLevel--;
if (mRange.parenthesisLevel<0)
mRange.parenthesisLevel=0;
popIndents(sitParenthesis); popIndents(sitParenthesis);
} }
@ -983,6 +987,8 @@ void SynEditCppHighlighter::squareCloseProc()
mTokenId = TokenKind::Symbol; mTokenId = TokenKind::Symbol;
mExtTokenId = ExtTokenKind::SquareClose; mExtTokenId = ExtTokenKind::SquareClose;
mRange.bracketLevel--; mRange.bracketLevel--;
if (mRange.bracketLevel<0)
mRange.bracketLevel=0;
popIndents(sitBracket); popIndents(sitBracket);
} }

View File

@ -316,6 +316,8 @@ void SynEditGLSLHighlighter::braceCloseProc()
} }
mRange.braceLevel -= 1; mRange.braceLevel -= 1;
if (mRange.braceLevel<0)
mRange.braceLevel = 0;
if (mRange.leftBraces>0) { if (mRange.leftBraces>0) {
mRange.leftBraces--; mRange.leftBraces--;
} else { } else {
@ -851,6 +853,8 @@ void SynEditGLSLHighlighter::roundCloseProc()
mTokenId = TokenKind::Symbol; mTokenId = TokenKind::Symbol;
mExtTokenId = ExtTokenKind::RoundClose; mExtTokenId = ExtTokenKind::RoundClose;
mRange.parenthesisLevel--; mRange.parenthesisLevel--;
if (mRange.parenthesisLevel<0)
mRange.parenthesisLevel=0;
popIndents(sitParenthesis); popIndents(sitParenthesis);
} }
@ -925,6 +929,8 @@ void SynEditGLSLHighlighter::squareCloseProc()
mTokenId = TokenKind::Symbol; mTokenId = TokenKind::Symbol;
mExtTokenId = ExtTokenKind::SquareClose; mExtTokenId = ExtTokenKind::SquareClose;
mRange.bracketLevel--; mRange.bracketLevel--;
if (mRange.bracketLevel<0)
mRange.bracketLevel=0;
popIndents(sitBracket); popIndents(sitBracket);
} }