- change: sort local identifiers before keywords in the auto completion popup

This commit is contained in:
Roy Qu 2022-07-22 21:02:07 +08:00
parent a09c5f26b4
commit eebd7336c2
2 changed files with 19 additions and 9 deletions

View File

@ -11,6 +11,7 @@ Red Panda C++ Version 1.1.5
- enhancement: add "Go to Line..." in the Code menu - enhancement: add "Go to Line..." in the Code menu
- fix: "Timeout for problem case" can't be rechecked, in the Settings Dialog -> executor -> problem set panel. - fix: "Timeout for problem case" can't be rechecked, in the Settings Dialog -> executor -> problem set panel.
- fix: bug in the project template - fix: bug in the project template
- change: sort local identifiers before keywords in the auto completion popup
Red Panda C++ Version 1.1.4 Red Panda C++ Version 1.1.4

View File

@ -264,14 +264,18 @@ static bool sortByScopeComparator(PStatement statement1,PStatement statement2){
return statement1->command < statement2->command; return statement1->command < statement2->command;
} else if (statement2->kind == StatementKind::skUserCodeSnippet) { } else if (statement2->kind == StatementKind::skUserCodeSnippet) {
return false; return false;
// show keywords first // show non-system defines before keyword
} else if (statement1->kind == StatementKind::skKeyword) { } else if (statement1->kind == StatementKind::skKeyword) {
if (statement2->kind != StatementKind::skKeyword) if (statement2->kind != StatementKind::skKeyword) {
return true; //s1 keyword / s2 system defines, s1 < s2, should return true
else //s1 keyword / s2 not system defines, s2 < s1, should return false;
return statement2->inSystemHeader;
} else
return statement1->command < statement2->command; return statement1->command < statement2->command;
} else if (statement2->kind == StatementKind::skKeyword) { } else if (statement2->kind == StatementKind::skKeyword) {
return false; //s1 system defines / s2 keyword, s2 < s1, should return false;
//s1 not system defines / s2 keyword, s1 < s2, should return true;
return (!statement1->inSystemHeader);
} }
// Show stuff from local headers first // Show stuff from local headers first
if (statement1->inSystemHeader != statement2->inSystemHeader) if (statement1->inSystemHeader != statement2->inSystemHeader)
@ -341,13 +345,18 @@ static bool sortByScopeWithUsageComparator(PStatement statement1,PStatement stat
if (statement1->usageCount != statement2->usageCount) if (statement1->usageCount != statement2->usageCount)
return statement1->usageCount > statement2->usageCount; return statement1->usageCount > statement2->usageCount;
// show non-system defines before keyword
if (statement1->kind == StatementKind::skKeyword) { if (statement1->kind == StatementKind::skKeyword) {
if (statement2->kind != StatementKind::skKeyword) if (statement2->kind != StatementKind::skKeyword) {
return true; //s1 keyword / s2 system defines, s1 < s2, should return true
else //s1 keyword / s2 not system defines, s2 < s1, should return false;
return statement2->inSystemHeader;
} else
return statement1->command < statement2->command; return statement1->command < statement2->command;
} else if (statement2->kind == StatementKind::skKeyword) { } else if (statement2->kind == StatementKind::skKeyword) {
return false; //s1 system defines / s2 keyword, s2 < s1, should return false;
//s1 not system defines / s2 keyword, s1 < s2, should return true;
return (!statement1->inSystemHeader);
} }
// Show stuff from local headers first // Show stuff from local headers first
if (statement1->inSystemHeader != statement2->inSystemHeader) if (statement1->inSystemHeader != statement2->inSystemHeader)