Skip to content

Commit

Permalink
Merge pull request godotengine#26224 from hilfazer/autocomplete
Browse files Browse the repository at this point in the history
Working autocomplete for $" and $'
  • Loading branch information
akien-mga authored Apr 30, 2019
2 parents 88c0a8d + 17166f5 commit 2cc8848
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scene/gui/text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5849,13 +5849,19 @@ void TextEdit::_update_completion_candidates() {

bool inquote = false;
int first_quote = -1;
int restore_quotes = -1;

int c = cofs - 1;
while (c >= 0) {
if (l[c] == '"' || l[c] == '\'') {
inquote = !inquote;
if (first_quote == -1)
first_quote = c;
restore_quotes = 0;
} else if (restore_quotes == 0 && l[c] == '$') {
restore_quotes = 1;
} else if (restore_quotes == 0 && !_is_whitespace(l[c])) {
restore_quotes = -1;
}
c--;
}
Expand Down Expand Up @@ -5923,6 +5929,11 @@ void TextEdit::_update_completion_candidates() {
completion_strings.write[i] = completion_strings[i].unquote().quote("'");
}

if (inquote && restore_quotes == 1 && !completion_strings[i].is_quoted()) {
String quote = single_quote ? "'" : "\"";
completion_strings.write[i] = completion_strings[i].quote(quote);
}

if (completion_strings[i].begins_with(s)) {
completion_options.push_back(completion_strings[i]);
} else if (completion_strings[i].to_lower().begins_with(s.to_lower())) {
Expand Down

0 comments on commit 2cc8848

Please sign in to comment.