fix #286 : Show type completion info after 'const' and 'volatile'
This commit is contained in:
parent
94f4587461
commit
92407fc767
1
NEWS.md
1
NEWS.md
|
@ -60,6 +60,7 @@ Red Panda C++ Version 2.27
|
||||||
- fix: Custom compile options not correctly parsed.
|
- fix: Custom compile options not correctly parsed.
|
||||||
- enhancement: "Mouse scroll direction" option in Options / Editor / General
|
- enhancement: "Mouse scroll direction" option in Options / Editor / General
|
||||||
- change: Invert scroll direction in horizontal, like in vertical.
|
- change: Invert scroll direction in horizontal, like in vertical.
|
||||||
|
- enhancement: Show type completion info after 'const' and 'volatile'
|
||||||
|
|
||||||
Red Panda C++ Version 2.26
|
Red Panda C++ Version 2.26
|
||||||
- enhancement: Code suggestion for embedded std::vectors.
|
- enhancement: Code suggestion for embedded std::vectors.
|
||||||
|
|
|
@ -876,9 +876,16 @@ void Editor::keyPressEvent(QKeyEvent *event)
|
||||||
handled=true;
|
handled=true;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
QString lastWord = getPreviousWordAtPositionForSuggestion(ws);
|
bool hasConst;
|
||||||
if (mParser && !lastWord.isEmpty()) {
|
QString lastWord = getPreviousWordAtPositionForSuggestion(ws, hasConst);
|
||||||
if (lastWord == "typedef" || lastWord == "const") {
|
if (mParser && (!lastWord.isEmpty() || hasConst)) {
|
||||||
|
if (lastWord.isEmpty()) {
|
||||||
|
Q_ASSERT(hasConst);
|
||||||
|
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||||
|
showCompletion(lastWord,false, CodeCompletionType::Types);
|
||||||
|
handled=true;
|
||||||
|
return;
|
||||||
|
} else if ( lastWord == "typedef" ) {
|
||||||
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
processCommand(QSynedit::EditCommand::Char,ch,nullptr);
|
||||||
showCompletion(lastWord,false, CodeCompletionType::Types);
|
showCompletion(lastWord,false, CodeCompletionType::Types);
|
||||||
handled=true;
|
handled=true;
|
||||||
|
@ -1436,7 +1443,8 @@ void Editor::inputMethodEvent(QInputMethodEvent *event)
|
||||||
int idCharPressed=caretX()-ws.ch;
|
int idCharPressed=caretX()-ws.ch;
|
||||||
idCharPressed += s.length();
|
idCharPressed += s.length();
|
||||||
if (idCharPressed>=pSettings->codeCompletion().minCharRequired()) {
|
if (idCharPressed>=pSettings->codeCompletion().minCharRequired()) {
|
||||||
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
|
bool hasConst;
|
||||||
|
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY(), hasConst);
|
||||||
if (mParser && !lastWord.isEmpty()) {
|
if (mParser && !lastWord.isEmpty()) {
|
||||||
if (CppTypeKeywords.contains(lastWord)) {
|
if (CppTypeKeywords.contains(lastWord)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4319,8 +4327,9 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
//handle class initializer
|
//handle class initializer
|
||||||
if (x >= 0 && hasPreviousWord) {
|
if (x >= 0 && hasPreviousWord) {
|
||||||
QSynedit::BufferCoord pos = pWordBegin;
|
QSynedit::BufferCoord pos = pWordBegin;
|
||||||
|
bool hasConst;
|
||||||
pos.ch = pWordBegin.ch;
|
pos.ch = pWordBegin.ch;
|
||||||
QString previousWord = getPreviousWordAtPositionForSuggestion(pos);
|
QString previousWord = getPreviousWordAtPositionForSuggestion(pos, hasConst);
|
||||||
|
|
||||||
PStatement statement = mParser->findStatementOf(
|
PStatement statement = mParser->findStatementOf(
|
||||||
mFilename,
|
mFilename,
|
||||||
|
@ -4912,8 +4921,9 @@ QString getWordAtPosition(QSynedit::QSynEdit *editor, const QSynedit::BufferCoor
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoord &p)
|
QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoord &p, bool &hasConst)
|
||||||
{
|
{
|
||||||
|
hasConst = false;
|
||||||
QString result;
|
QString result;
|
||||||
if ((p.line<1) || (p.line>document()->count())) {
|
if ((p.line<1) || (p.line>document()->count())) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -4969,8 +4979,12 @@ QString Editor::getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoo
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
result = s.mid(wordBegin, wordEnd - wordBegin+1);
|
result = s.mid(wordBegin, wordEnd - wordBegin+1);
|
||||||
if ((result != "const") && !skipNextWord)
|
if (result == "const" || result == "volatile")
|
||||||
|
hasConst = true;
|
||||||
|
else if (!skipNextWord)
|
||||||
break;
|
break;
|
||||||
|
// if ((result != "const") && !skipNextWord)
|
||||||
|
// break;
|
||||||
wordEnd = wordBegin-1;
|
wordEnd = wordBegin-1;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -184,7 +184,7 @@ public:
|
||||||
void removeBreakpointFocus();
|
void removeBreakpointFocus();
|
||||||
void modifyBreakpointProperty(int line);
|
void modifyBreakpointProperty(int line);
|
||||||
void setActiveBreakpointFocus(int Line, bool setFocus=true);
|
void setActiveBreakpointFocus(int Line, bool setFocus=true);
|
||||||
QString getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoord& p);
|
QString getPreviousWordAtPositionForSuggestion(const QSynedit::BufferCoord& p, bool &hasConst);
|
||||||
QString getPreviousWordAtPositionForCompleteFunctionDefinition(const QSynedit::BufferCoord& p);
|
QString getPreviousWordAtPositionForCompleteFunctionDefinition(const QSynedit::BufferCoord& p);
|
||||||
void reformat(bool doReparse=true);
|
void reformat(bool doReparse=true);
|
||||||
void checkSyntaxInBack();
|
void checkSyntaxInBack();
|
||||||
|
|
Loading…
Reference in New Issue