Skip to content

Commit 3a8049f

Browse files
committed
UI: completion includes non keywords
1 parent bb5d0b7 commit 3a8049f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/ui/textedit.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define TWISTY2_CLOSE " < "
3232
#define TWISTY1_LEN 2
3333
#define TWISTY2_LEN 4
34+
#define HELP_BG 0x73c990
35+
#define HELP_FG 0x20242a
3436

3537
int g_themeId = 0;
3638
int g_lineMarker[MAX_MARKERS] = {
@@ -1447,7 +1449,7 @@ TextEditHelpWidget::TextEditHelpWidget(TextEditInput *editor, int chW, int chH,
14471449
_editor(editor),
14481450
_openPackage(NULL),
14491451
_openKeyword(-1) {
1450-
_theme = new EditTheme(0x73c990, 0x20242a);
1452+
_theme = new EditTheme(HELP_BG, HELP_FG);
14511453
hide();
14521454
if (overlay) {
14531455
_x = editor->_width - (chW * HELP_WIDTH);
@@ -1574,12 +1576,31 @@ void TextEditHelpWidget::createCompletionHelp() {
15741576
char *selection = _editor->getWordBeforeCursor();
15751577
int len = selection != NULL ? strlen(selection) : 0;
15761578
if (len > 0) {
1579+
StringList words;
15771580
for (int i = 0; i < keyword_help_len; i++) {
15781581
if (strncasecmp(selection, keyword_help[i].keyword, len) == 0) {
1582+
words.add(keyword_help[i].keyword);
15791583
_buf.append(keyword_help[i].keyword);
15801584
_buf.append("\n", 1);
15811585
}
15821586
}
1587+
const char *found = strstr(_editor->getText(), selection);
1588+
while (found != NULL) {
1589+
const char *end = found;
1590+
while (!IS_WHITE(*end) && *end != '\0') {
1591+
end++;
1592+
}
1593+
if (end - found > len) {
1594+
String next;
1595+
next.append(found, end - found);
1596+
if (!words.exists(next)) {
1597+
words.add(next);
1598+
_buf.append(found, end - found);
1599+
_buf.append("\n", 1);
1600+
}
1601+
}
1602+
found = strstr(found + len, selection);
1603+
}
15831604
} else {
15841605
const char *package = NULL;
15851606
for (int i = 0; i < keyword_help_len; i++) {

0 commit comments

Comments
 (0)